diff libfdproto/dictionary_functions.c @ 1300:3f1e79e1273e

Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
author Sebastien Decugis <sdecugis@freediameter.net>
date Sun, 30 Aug 2015 01:11:55 +0800
parents 38e4a7c318ac
children 3cbe458fbfa9
line wrap: on
line diff
--- a/libfdproto/dictionary_functions.c	Sat Jul 04 23:06:37 2015 +0800
+++ b/libfdproto/dictionary_functions.c	Sun Aug 30 01:11:55 2015 +0800
@@ -358,3 +358,30 @@
 	return *buf;
 }
 
+/* Check that a given AVP value contains all the characters from data in the same order */
+static char error_message[80];
+int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg)
+{
+	char * inChar = data;
+	char * inData = (char *)val->os.data;
+	int i = 0;
+	CHECK_PARAMS(data);
+	while (*inChar != '\0') {
+		while (i < val->os.len) {
+			if (*inChar == inData[i++]) {
+				inChar++;
+				break;
+			}
+		}
+		if (i >= val->os.len)
+			break;
+	}
+	if (*inChar == '\0')
+		return 0;
+	
+	if (error_msg) {
+		snprintf(error_message, sizeof(error_message), "Could not find '%c' in AVP", *inChar);
+		*error_msg = error_message;
+	}
+	return EBADMSG;
+}
"Welcome to our mercurial repository"