Navigation



Ignore:
Timestamp:
Aug 30, 2015, 2:11:55 AM (9 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/dictionary_functions.c

    r1284 r1300  
    359359}
    360360
     361/* Check that a given AVP value contains all the characters from data in the same order */
     362static char error_message[80];
     363int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg)
     364{
     365        char * inChar = data;
     366        char * inData = (char *)val->os.data;
     367        int i = 0;
     368        CHECK_PARAMS(data);
     369        while (*inChar != '\0') {
     370                while (i < val->os.len) {
     371                        if (*inChar == inData[i++]) {
     372                                inChar++;
     373                                break;
     374                        }
     375                }
     376                if (i >= val->os.len)
     377                        break;
     378        }
     379        if (*inChar == '\0')
     380                return 0;
     381       
     382        if (error_msg) {
     383                snprintf(error_message, sizeof(error_message), "Could not find '%c' in AVP", *inChar);
     384                *error_msg = error_message;
     385        }
     386        return EBADMSG;
     387}
Note: See TracChangeset for help on using the changeset viewer.