Mercurial > hg > waaad
changeset 77:425b707d20bb
Add a 'order' parameter to FIXED rules
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 11 Jul 2008 18:02:38 +0900 |
parents | 419c158636e2 |
children | b9bc2d2a12a6 |
files | include/waaad/dictionary-api.h waaad/dict-base.c waaad/dictionary.c |
diffstat | 3 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/include/waaad/dictionary-api.h Fri Jul 11 14:00:33 2008 +0900 +++ b/include/waaad/dictionary-api.h Fri Jul 11 18:02:38 2008 +0900 @@ -757,16 +757,17 @@ /* This type defines the kind of rule that must be defined */ typedef enum { - RULE_FIXED_HEAD = 1, /* The AVP must be at the head of the group. No order is guaranteed between several RULE_FIXED_HEAD rules */ + RULE_FIXED_HEAD = 1, /* The AVP must be at the head of the group. The rule_order field is used to specify the position. */ RULE_REQUIRED, /* The AVP must be present in the parent, but its position is not defined. */ RULE_OPTIONAL, /* The AVP may be present in the message. Used to specify a max number of occurences for example */ - RULE_FIXED_TAIL /* The AVP must be at the end of the group. No order is guaranteed between several RULE_FIXED_TAIL rules */ + RULE_FIXED_TAIL /* The AVP must be at the end of the group. The rule_order field is used to specify the position. */ } rule_position_t; /* This type holds the values for the rule being defined */ typedef struct { dict_object_t *rule_avp; /* Pointer to the AVP object that is concerned by this rule */ rule_position_t rule_position; /* The position in which the rule_avp must appear in the parent */ + int rule_order; /* for RULE_FIXED_* rules, the place. 1,2,3.. for HEAD rules; ...,3,2,1 for TAIL rules. */ int rule_min; /* Minimum number of occurences. -1 means "default": 0 for optional rules, 1 for other rules */ int rule_max; /* Maximum number of occurences. -1 means no maximum. 0 means the AVP is forbidden. */ int rule_template; /* Number of this AVP to place in a template message. Must be between rule_min and rule_max */
--- a/waaad/dict-base.c Fri Jul 11 14:00:33 2008 +0900 +++ b/waaad/dict-base.c Fri Jul 11 18:02:38 2008 +0900 @@ -72,6 +72,7 @@ for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) { \ dict_rule_data_t __data = { NULL, \ (_rulearray)[__ar].position, \ + 1, /* at most 1 fixed rule in base protocol */ \ (_rulearray)[__ar].min, \ (_rulearray)[__ar].max, \ (_rulearray)[__ar].template}; \ @@ -680,7 +681,7 @@ /* Now create the rules for the Proxy-Info AVP */ { - dict_rule_data_t rule_data = { NULL, RULE_REQUIRED, 1, 1, 1 }; + dict_rule_data_t rule_data = { NULL, RULE_REQUIRED, 1, 0, 1, 1 }; rule_data.rule_avp = Proxy_Host_avp; CHECK_dict_new( DICT_RULE, &rule_data, Proxy_Info_avp, NULL); @@ -845,6 +846,7 @@ /* Create the rule for the required element */ rule_data.rule_avp = Vendor_Id_avp; rule_data.rule_position = RULE_REQUIRED; + rule_data.rule_order = 0; rule_data.rule_min = 1; rule_data.rule_max = 1; rule_data.rule_template = 1;
--- a/waaad/dictionary.c Fri Jul 11 14:00:33 2008 +0900 +++ b/waaad/dictionary.c Fri Jul 11 18:02:38 2008 +0900 @@ -1281,8 +1281,9 @@ static void dump_rule_data ( void * data ) { dict_rule_data_t * rule = (dict_rule_data_t * )data; - log_debug("data: pos:%d m/M/t:%2d/%2d/%2d avp:\"%s\"", + log_debug("data: pos:%d ord:%d m/M/t:%2d/%2d/%2d avp:\"%s\"", rule->rule_position, + rule->rule_order, rule->rule_min, rule->rule_max, rule->rule_template,