Navigation


Changeset 705:f0cb8f465763 in freeDiameter for extensions/app_radgw/rgwx_auth.c


Ignore:
Timestamp:
Jan 31, 2011, 5:22:21 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added standard Result-Code values in header.
Added Error-Cause attribute conversion in app_radgw.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgwx_auth.c

    r703 r705  
    5151#define ACV_ASS_STATE_MAINTAINED        0       /* STATE_MAINTAINED */
    5252#define ACV_ASS_NO_STATE_MAINTAINED     1       /* NO_STATE_MAINTAINED */
    53 #define ER_DIAMETER_MULTI_ROUND_AUTH    1001
    54 #define ER_DIAMETER_LIMITED_SUCCESS     2002
    5553
    5654/* The state we keep for this plugin */
     
    10761074        uint8_t tuntag = 0;
    10771075        unsigned char * req_auth = NULL;
     1076        int error_cause = 0;
    10781077       
    10791078        TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli);
     
    11611160               
    11621161                default:
     1162                        /* Can we convert the value to a natural Error-Cause ? */
     1163                        switch (ahdr->avp_value->u32) {
     1164                                case ER_DIAMETER_AVP_UNSUPPORTED:
     1165                                        error_cause = 401; /* Unsupported Attribute */
     1166                                        break;
     1167                                       
     1168                                case ER_DIAMETER_MISSING_AVP:
     1169                                        error_cause = 402; /* Missing Attribute */
     1170                                        break;
     1171                                       
     1172                                case ER_DIAMETER_UNABLE_TO_COMPLY:
     1173                                        error_cause = 404; /* Invalid Request */
     1174                                        break;
     1175                                       
     1176                                case ER_DIAMETER_APPLICATION_UNSUPPORTED:
     1177                                        error_cause = 405; /* Unsupported Service */
     1178                                        break;
     1179                                       
     1180                                case ER_DIAMETER_COMMAND_UNSUPPORTED:
     1181                                        error_cause = 406; /* Unsupported Extension */
     1182                                        break;
     1183                                       
     1184                                case ER_DIAMETER_INVALID_AVP_VALUE:
     1185                                        error_cause = 407; /* Invalid Attribute Value */
     1186                                        break;
     1187                                       
     1188                                case ER_DIAMETER_AVP_NOT_ALLOWED:
     1189                                        error_cause = 501; /* Administratively Prohibited */
     1190                                        break;
     1191                                       
     1192                                case ER_DIAMETER_REALM_NOT_SERVED:
     1193                                case ER_DIAMETER_LOOP_DETECTED:
     1194                                case ER_DIAMETER_UNKNOWN_PEER:
     1195                                case ER_DIAMETER_UNABLE_TO_DELIVER:
     1196                                        error_cause = 502; /* Request Not Routable (Proxy) */
     1197                                        break;
     1198                                       
     1199                                case ER_DIAMETER_UNKNOWN_SESSION_ID:
     1200                                        error_cause = 503; /* Session Context Not Found */
     1201                                        break;
     1202                                       
     1203                                case ER_DIAMETER_TOO_BUSY:
     1204                                case ER_DIAMETER_OUT_OF_SPACE:
     1205                                        error_cause = 506; /* Resources Unavailable */
     1206                                        break;
     1207                                       
     1208#if 0
     1209                        /* remaining Diameter Result-Code & RADIUS Error-Cause */
     1210                                case ER_DIAMETER_REDIRECT_INDICATION:
     1211                                case ER_DIAMETER_INVALID_HDR_BITS:
     1212                                case ER_DIAMETER_INVALID_AVP_BITS:
     1213                                case ER_DIAMETER_AUTHENTICATION_REJECTED:
     1214                                case ER_ELECTION_LOST:
     1215                                case ER_DIAMETER_AUTHORIZATION_REJECTED:
     1216                                case ER_DIAMETER_RESOURCES_EXCEEDED:
     1217                                case ER_DIAMETER_CONTRADICTING_AVPS:
     1218                                case ER_DIAMETER_AVP_OCCURS_TOO_MANY_TIMES
     1219                                case ER_DIAMETER_NO_COMMON_APPLICATION:
     1220                                case ER_DIAMETER_UNSUPPORTED_VERSION:
     1221                                case ER_DIAMETER_INVALID_BIT_IN_HEADER:
     1222                                case ER_DIAMETER_INVALID_AVP_LENGTH:
     1223                                case ER_DIAMETER_INVALID_MESSAGE_LENGTH:
     1224                                case ER_DIAMETER_INVALID_AVP_BIT_COMBO:
     1225                                case ER_DIAMETER_NO_COMMON_SECURITY:
     1226                                        error_cause = 403; /* NAS Identification Mismatch */
     1227                                        error_cause = 504; /* Session Context Not Removable */
     1228                                        error_cause = 505; /* Other Proxy Processing Error */
     1229                                        error_cause = 507; /* Request Initiated */
     1230                                        error_cause = 508; /* Multiple Session Selection Unsupported */
     1231#endif /* 0 */
     1232                        }
     1233                        /* In any case, the following is processed: */
    11631234                        (*rad_fw)->hdr->code = RADIUS_CODE_ACCESS_REJECT;
    11641235                        fd_log_debug("[auth.rgwx] Received Diameter answer with error code '%d' from server '%.*s', session %.*s, translating into Access-Reject\n",
     
    18251896                                        }
    18261897                                       
    1827                                         if ( ! radius_msg_add_attr_int32(*rad_fw, RADIUS_ATTR_ERROR_CAUSE, 202) ) {
    1828                                                 TRACE_DEBUG(INFO, "Error while adding Error-Cause attribute in RADIUS message");
    1829                                                 return ENOMEM;
    1830                                         }
     1898                                        error_cause = 202; /* Invalid EAP Packet */
    18311899                                        break;
    18321900                       
     
    18521920        CHECK_FCT( fd_msg_free( aoh ) );
    18531921        free(req_auth);
     1922       
     1923        if (error_cause) {
     1924                if ( ! radius_msg_add_attr_int32(*rad_fw, RADIUS_ATTR_ERROR_CAUSE, error_cause) ) {
     1925                        TRACE_DEBUG(INFO, "Error while adding Error-Cause attribute in RADIUS message");
     1926                        return ENOMEM;
     1927                }
     1928        }               
    18541929
    18551930        if ((*rad_fw)->hdr->code == RADIUS_CODE_ACCESS_ACCEPT) {
Note: See TracChangeset for help on using the changeset viewer.