Navigation


Changeset 116:638647100330 in freeDiameter for freeDiameter/messages.c


Ignore:
Timestamp:
Dec 8, 2009, 5:30:01 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Changed function to accept invalid ABNF in error messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/messages.c

    r115 r116  
    300300        fd_msg_dump_walk(NONE, m);
    301301       
     302        CHECK_FCT( fd_msg_hdr(m, &hdr) );
     303       
    302304        /* Now create an answer error if the message is a query */
    303         CHECK_FCT( fd_msg_hdr(m, &hdr) );
    304        
    305305        if (hdr->msg_flags & CMD_FLAG_REQUEST) {
    306306               
     
    312312               
    313313        } else {
     314                do { /* Rescue error messages */
     315                        struct avp * avp;
     316                        union avp_value * rc = NULL;
     317                       
     318                        /* Search the Result-Code AVP */
     319                        CHECK_FCT_DO(  fd_msg_browse(*msg, MSG_BRW_FIRST_CHILD, &avp, NULL), break  );
     320                        while (avp) {
     321                                struct avp_hdr * ahdr;
     322                                CHECK_FCT_DO(  fd_msg_avp_hdr( avp, &ahdr ), break  );
     323                               
     324                                if ((ahdr->avp_code == AC_RESULT_CODE) && (! (ahdr->avp_flags & AVP_FLAG_VENDOR)) ) {
     325                                        /* Parse this AVP */
     326                                        ASSERT( ahdr->avp_value );
     327                                        rc = ahdr->avp_value;
     328                                        break;
     329                                }
     330                               
     331                                /* Go to next AVP */
     332                                CHECK_FCT_DO(  fd_msg_browse(avp, MSG_BRW_NEXT, &avp, NULL), break  );
     333                        }
     334                       
     335                        if (rc) {
     336                                switch (rc->u32 / 1000) {
     337                                        case 1: /* 1xxx : Informational */
     338                                        case 2: /* 2xxx : Sucess */
     339                                                /* In these cases, we want the message to validate the ABNF, so we will discard the bad message */
     340                                                break;
     341                                               
     342                                        default: /* Other errors */
     343                                                /* We let the application decide what to do with the message, we rescue it */
     344                                                return 0;
     345                                }
     346                        }
     347                } while (0);
     348               
    314349                /* Just discard */
    315350                CHECK_FCT( fd_msg_free( m ) );
Note: See TracChangeset for help on using the changeset viewer.