diff options
Diffstat (limited to 'libfdcore/dict_base_proto.c')
| -rw-r--r-- | libfdcore/dict_base_proto.c | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/libfdcore/dict_base_proto.c b/libfdcore/dict_base_proto.c index 5c023f6..5eb7c58 100644 --- a/libfdcore/dict_base_proto.c +++ b/libfdcore/dict_base_proto.c @@ -2,7 +2,7 @@ * Software License Agreement (BSD License) * * Author: Sebastien Decugis <sdecugis@freediameter.net> * * * -* Copyright (c) 2013, WIDE Project and NICT * +* Copyright (c) 2020, WIDE Project and NICT * * All rights reserved. * * * * Redistribution and use of this software in source and binary forms, with or without modification, are * @@ -1582,7 +1582,37 @@ int fd_dict_base_protocol(struct dictionary * dict) }; CHECK_dict_new( DICT_AVP, &data , NULL, NULL); } - + + /* Experimental-Result-Code */ + { + /* + The Experimental-Result-Code AVP (AVP Code 298) is of type Unsigned32 + and contains a vendor-assigned value representing the result of + processing the request. + + It is recommended that vendor-specific result codes follow the same + conventions given for the Result-Code AVP regarding the different + types of result codes and the handling of errors (for non 2xxx + values). + */ + /* Although the RFC does not specify an "Enumerated" type here, we go forward and create one. + * This is the reason for the "*" in the type name. Vendors will have to define their values. + */ + struct dict_object * type; + struct dict_type_data tdata = { AVP_TYPE_UNSIGNED32, "Enumerated(Experimental-Result-Code)" , NULL, NULL, NULL }; + struct dict_avp_data data = { + 298, /* Code */ + 0, /* Vendor */ + "Experimental-Result-Code", /* Name */ + AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ + AVP_FLAG_MANDATORY, /* Fixed flag values */ + AVP_TYPE_UNSIGNED32 /* base type of data */ + }; + + CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type); + CHECK_dict_new( DICT_AVP, &data , type, NULL); + } + /* Experimental-Result */ { /* @@ -1594,8 +1624,8 @@ int fd_dict_base_protocol(struct dictionary * dict) AVP Format Experimental-Result ::= < AVP Header: 297 > - { Vendor-Id } - { Experimental-Result-Code } + { Vendor-Id } + { Experimental-Result-Code } The Vendor-Id AVP (see Section 5.3.3) in this grouped AVP identifies the vendor responsible for the assignment of the result code which @@ -1603,47 +1633,23 @@ int fd_dict_base_protocol(struct dictionary * dict) applications MUST include either one Result-Code AVP or one Experimental-Result AVP. */ - struct dict_avp_data data = { - 297, /* Code */ - 0, /* Vendor */ - "Experimental-Result", /* Name */ - AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ + struct dict_object * avp = NULL; + struct dict_avp_data data = { + 297, /* Code */ + 0, /* Vendor */ + "Experimental-Result", /* Name */ + AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ AVP_FLAG_MANDATORY, /* Fixed flag values */ - AVP_TYPE_GROUPED /* base type of data */ + AVP_TYPE_GROUPED /* base type of data */ }; - CHECK_dict_new( DICT_AVP, &data , NULL, NULL); + struct local_rules_definition rules[] = { + { "Vendor-Id", RULE_REQUIRED, -1, 1 }, + { "Experimental-Result-Code", RULE_REQUIRED, -1, 1 }, + }; + CHECK_dict_new( DICT_AVP, &data , NULL, &avp); + PARSE_loc_rules( rules, avp ); } - - /* Experimental-Result-Code */ - { - /* - The Experimental-Result-Code AVP (AVP Code 298) is of type Unsigned32 - and contains a vendor-assigned value representing the result of - processing the request. - It is recommended that vendor-specific result codes follow the same - conventions given for the Result-Code AVP regarding the different - types of result codes and the handling of errors (for non 2xxx - values). - */ - /* Although the RFC does not specify an "Enumerated" type here, we go forward and create one. - * This is the reason for the "*" in the type name. Vendors will have to define their values. - */ - struct dict_object * type; - struct dict_type_data tdata = { AVP_TYPE_UNSIGNED32, "Enumerated(Experimental-Result-Code)" , NULL, NULL, NULL }; - struct dict_avp_data data = { - 298, /* Code */ - 0, /* Vendor */ - "Experimental-Result-Code", /* Name */ - AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ - AVP_FLAG_MANDATORY, /* Fixed flag values */ - AVP_TYPE_UNSIGNED32 /* base type of data */ - }; - - CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type); - CHECK_dict_new( DICT_AVP, &data , type, NULL); - } - /* Auth-Request-Type */ { /* |
