Mercurial > hg > freeDiameter
comparison include/freeDiameter/libfdproto.h @ 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 | a22d9e907d48 |
children | 090390e89b1d |
comparison
equal
deleted
inserted
replaced
1299:035f489b845b | 1300:3f1e79e1273e |
---|---|
1256 * 0 : Operation complete. | 1256 * 0 : Operation complete. |
1257 * !0 : An error occurred, the error code is returned. | 1257 * !0 : An error occurred, the error code is returned. |
1258 */ | 1258 */ |
1259 typedef int (*dict_avpdata_encode) (void * data, union avp_value * val); | 1259 typedef int (*dict_avpdata_encode) (void * data, union avp_value * val); |
1260 | 1260 |
1261 /* | |
1262 * CALLBACK: dict_avpdata_check | |
1263 * | |
1264 * PARAMETERS: | |
1265 * val : Pointer to the AVP value that was received and needs to be sanity checked. | |
1266 * data : a parameter stored in the type structure (to enable more generic check functions) | |
1267 * error_msg: upon erroneous value, a string describing the error can be returned here (it will be strcpy by caller). This description will be returned in the error message, if any. | |
1268 * | |
1269 * DESCRIPTION: | |
1270 * This callback can be provided with a derived type in order to improve the operation of the | |
1271 * fd_msg_parse_dict function. When this callback is present, the value of the AVP that has | |
1272 * been parsed is passed to this function for finer granularity check. For example for some | |
1273 * speccific AVP, the format of an OCTETSTRING value can be further checked, or the | |
1274 * interger value can be verified. | |
1275 * | |
1276 * RETURN VALUE: | |
1277 * 0 : The value is valid. | |
1278 * !0 : An error occurred, the error code is returned. It is advised to return EINVAL on incorrect val | |
1279 */ | |
1280 typedef int (*dict_avpdata_check) (void * data, union avp_value * val, char ** error_msg); | |
1281 | |
1282 | |
1261 | 1283 |
1262 /* Type to hold data associated to a derived AVP data type */ | 1284 /* Type to hold data associated to a derived AVP data type */ |
1263 struct dict_type_data { | 1285 struct dict_type_data { |
1264 enum dict_avp_basetype type_base; /* How the data of such AVP must be interpreted */ | 1286 enum dict_avp_basetype type_base; /* How the data of such AVP must be interpreted */ |
1265 char * type_name; /* The name of this type */ | 1287 char * type_name; /* The name of this type */ |
1266 dict_avpdata_interpret type_interpret;/* cb to convert the AVP value in more comprehensive format (or NULL) */ | 1288 dict_avpdata_interpret type_interpret;/* cb to convert the AVP value in more comprehensive format (or NULL) */ |
1267 dict_avpdata_encode type_encode; /* cb to convert formatted data into an AVP value (or NULL) */ | 1289 dict_avpdata_encode type_encode; /* cb to convert formatted data into an AVP value (or NULL) */ |
1268 DECLARE_FD_DUMP_PROTOTYPE((*type_dump), union avp_value * val); /* cb called by fd_msg_dump_* for this type of data (if != NULL). Returned string must be freed. */ | 1290 DECLARE_FD_DUMP_PROTOTYPE((*type_dump), union avp_value * val); /* cb called by fd_msg_dump_* for this type of data (if != NULL). Returned string must be freed. */ |
1291 dict_avpdata_check type_check; | |
1292 void * type_check_param; | |
1269 }; | 1293 }; |
1270 | 1294 |
1271 /* The criteria for searching a type object in the dictionary */ | 1295 /* The criteria for searching a type object in the dictionary */ |
1272 enum { | 1296 enum { |
1273 TYPE_BY_NAME = 30, /* "what" points to a char * */ | 1297 TYPE_BY_NAME = 30, /* "what" points to a char * */ |
1290 /* For Time AVPs, map with time_t value directly */ | 1314 /* For Time AVPs, map with time_t value directly */ |
1291 int fd_dictfct_Time_encode(void * data, union avp_value * avp_value); | 1315 int fd_dictfct_Time_encode(void * data, union avp_value * avp_value); |
1292 int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted); | 1316 int fd_dictfct_Time_interpret(union avp_value * avp_value, void * interpreted); |
1293 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value); | 1317 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value); |
1294 | 1318 |
1319 | |
1320 /* For string AVP, the following type_check function provides simple basic check for specific characters presence, e.g. use "@." for trivial email address check */ | |
1321 int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg); | |
1295 | 1322 |
1296 | 1323 |
1297 /****/ | 1324 /****/ |
1298 | 1325 |
1299 /*** | 1326 /*** |