Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Dictionary definitions of objects specified in DCCA (Nokia, 3GPP). |
| 3 | */ |
| 4 | #include <freeDiameter/extension.h> |
| 5 | |
| 6 | |
| 7 | /* The content of this file follows the same structure as dict_base_proto.c */ |
| 8 | |
| 9 | #define CHECK_dict_new( _type, _data, _parent, _ref ) \ |
| 10 | CHECK_FCT( fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref)) ); |
| 11 | |
| 12 | #define CHECK_dict_search( _type, _criteria, _what, _result ) \ |
| 13 | CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) ); |
| 14 | |
| 15 | struct local_rules_definition { |
| 16 | char *avp_name; |
| 17 | enum rule_position position; |
| 18 | int min; |
| 19 | int max; |
| 20 | }; |
| 21 | |
| 22 | #define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 ) |
| 23 | |
| 24 | #define PARSE_loc_rules( _rulearray, _parent) { \ |
| 25 | int __ar; \ |
| 26 | for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) { \ |
| 27 | struct dict_rule_data __data = { NULL, \ |
| 28 | (_rulearray)[__ar].position, \ |
| 29 | 0, \ |
| 30 | (_rulearray)[__ar].min, \ |
| 31 | (_rulearray)[__ar].max}; \ |
| 32 | __data.rule_order = RULE_ORDER(__data.rule_position); \ |
| 33 | CHECK_FCT( fd_dict_search( \ |
| 34 | fd_g_config->cnf_dict, \ |
| 35 | DICT_AVP, \ |
| 36 | AVP_BY_NAME, \ |
| 37 | (_rulearray)[__ar].avp_name, \ |
| 38 | &__data.rule_avp, 0 ) ); \ |
| 39 | if ( !__data.rule_avp ) { \ |
| 40 | TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name ); \ |
| 41 | return ENOENT; \ |
| 42 | } \ |
| 43 | CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL), \ |
| 44 | { \ |
| 45 | TRACE_DEBUG(INFO, "Error on rule with AVP '%s'", \ |
| 46 | (_rulearray)[__ar].avp_name ); \ |
| 47 | return EINVAL; \ |
| 48 | } ); \ |
| 49 | } \ |
| 50 | } |
| 51 | |
| 52 | #define enumval_def_u32( _val_, _str_ ) \ |
| 53 | { _str_, { .u32 = _val_ }} |
| 54 | |
| 55 | #define enumval_def_os( _len_, _val_, _str_ ) \ |
| 56 | { _str_, { .os = { .data = (unsigned char *)_val_, .len = _len_ }}} |
| 57 | |
| 58 | |
| 59 | static int dict_dcca_nokia_entry(char * conffile) |
| 60 | { |
| 61 | TRACE_ENTRY("%p", conffile); |
| 62 | |
| 63 | /* Applications section */ |
| 64 | { |
| 65 | /* Create the vendors */ |
| 66 | { |
| 67 | struct dict_vendor_data vendor_data = { 94, "Nokia" }; |
| 68 | CHECK_FCT(fd_dict_new(fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data, NULL, NULL)); |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 | |
| 74 | /* AVP section */ |
| 75 | { |
| 76 | struct dict_object * Address_type; |
| 77 | struct dict_object * UTF8String_type; |
| 78 | struct dict_object * DiameterIdentity_type; |
| 79 | struct dict_object * DiameterURI_type; |
| 80 | struct dict_object * Time_type; |
| 81 | |
| 82 | CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Address", &Address_type); |
| 83 | CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "UTF8String", &UTF8String_type); |
| 84 | CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterIdentity", &DiameterIdentity_type); |
| 85 | CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterURI", &DiameterURI_type); |
| 86 | CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Time", &Time_type); |
| 87 | |
| 88 | /* NSN-Token-Value */ |
| 89 | { |
| 90 | /* |
| 91 | OctetString. A token that was received, for |
| 92 | example, from the subscription portal [14]. The |
| 93 | maximum length of the token is 64 octets. |
| 94 | When this AVP is included in the MSCC, the USU |
| 95 | and Reporting-Reason AVPs will not be included |
| 96 | (because the token is not a trigger to report quota |
| 97 | usage). Additionally, the Rating-Group and |
| 98 | Service-Id AVPs will have the values received |
| 99 | from the subscription portal. |
| 100 | */ |
| 101 | struct dict_avp_data data = { |
| 102 | 5113, /* Code */ |
| 103 | 94, /* Vendor */ |
| 104 | "NSN-Token-Value", /* Name */ |
| 105 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 106 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */ |
| 107 | AVP_TYPE_OCTETSTRING /* base type of data */ |
| 108 | }; |
| 109 | CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 110 | } |
| 111 | |
| 112 | /* Quota-Consumption-Time */ |
| 113 | { |
| 114 | /* |
| 115 | Unsigned32. Contains the time quota envelope |
| 116 | expiration time in seconds. This is the time |
| 117 | elapsed from the previous service request, to |
| 118 | the moment the Flexi ISN considers that the |
| 119 | time envelope finishes. The value of this AVP |
| 120 | will be in effect for the remainder of the session |
| 121 | or until a new value is received. If this AVP is |
| 122 | not present, the default value configured for the |
| 123 | rating group will be used. The OCS may |
| 124 | disable the time quota envelope expiration by |
| 125 | setting the value of this AVP to 0. The value of |
| 126 | QCT sent from the OCS for a certain MSCC |
| 127 | instance is stored in the Flexi ISN and it is used |
| 128 | if the OCS does not sent a new value in the |
| 129 | CCAs that follow |
| 130 | */ |
| 131 | struct dict_avp_data data = { |
| 132 | 5109, /* Code */ |
| 133 | 94, /* Vendor */ |
| 134 | "Quota-Consumption-Time", /* Name */ |
| 135 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 136 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */ |
| 137 | AVP_TYPE_UNSIGNED32 /* base type of data */ |
| 138 | }; |
| 139 | CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 140 | } |
| 141 | |
| 142 | /* Quota-Holding-Time */ |
| 143 | { |
| 144 | /* |
| 145 | Unsigned32. Indicates how long the Flexi ISN |
| 146 | will keep the granted quota after a service |
| 147 | request has been received. The unit is in |
| 148 | seconds. When this time elapses, the Flexi ISN |
| 149 | ends the MSCC instance and reports the used |
| 150 | quota without requesting more. The value of |
| 151 | this AVP will be in effect for the remainder of |
| 152 | the session or until a new value is received. If |
| 153 | this AVP is not present, the default value con- |
| 154 | figured for the rating group will be used. The |
| 155 | OCS may disable the Quota Holding Timer by |
| 156 | setting the value of this AVP to 0. The value of |
| 157 | the QHT sent from the OCS for a certain |
| 158 | MSCC instance is stored in the Flexi ISN, and |
| 159 | it is used if the OCS does not sent a new value |
| 160 | in the CCAs that follow. |
| 161 | */ |
| 162 | struct dict_avp_data data = { |
| 163 | 5110, /* Code */ |
| 164 | 94, /* Vendor */ |
| 165 | "Quota-Holding-Time", /* Name */ |
| 166 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 167 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */ |
| 168 | AVP_TYPE_UNSIGNED32 /* base type of data */ |
| 169 | }; |
| 170 | CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 171 | } |
| 172 | |
| 173 | /* Default-Quota */ |
| 174 | { |
| 175 | /* |
| 176 | Grouped. Indicates the absolute number of |
| 177 | units that are available for consumption during |
| 178 | each upcoming OCS interrogation (e.g. after a |
| 179 | CCR has been sent but before the CCA is |
| 180 | received). If this AVP is not present, the Flexi |
| 181 | ISN will use the configured or earlier received |
| 182 | default quota. If this AVP is present but does |
| 183 | not include the default quota for a certain unit |
| 184 | type, that unit type is considered to have no |
| 185 | default quota. |
| 186 | The usage of default quota can be disabled in |
| 187 | certain situations by modifying the Flexi ISN |
| 188 | settings |
| 189 | */ |
| 190 | struct dict_avp_data data = { |
| 191 | 5111, /* Code */ |
| 192 | 94, /* Vendor */ |
| 193 | "Default-Quota", /* Name */ |
| 194 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 195 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flag values */ |
| 196 | AVP_TYPE_GROUPED /* base type of data */ |
| 197 | }; |
| 198 | CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 199 | } |
| 200 | |
| 201 | /* Session-Start-Indicator */ |
| 202 | { |
| 203 | /* |
| 204 | OctetString. (3GPP TS 29.061 Rel4). The address |
| 205 | of the charging gateway that has been marked as |
| 206 | the default charging gateway for the PDP context. |
| 207 | The address is expressed as a four-byte integer. |
| 208 | Present in the initial CCR only. |
| 209 | */ |
| 210 | struct dict_avp_data data = { |
| 211 | 5105, /* Code */ |
| 212 | 94, /* Vendor */ |
| 213 | "Session-Start-Indicator", /* Name */ |
| 214 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 215 | AVP_FLAG_VENDOR, /* Fixed flag values */ |
| 216 | AVP_TYPE_OCTETSTRING /* base type of data */ |
| 217 | }; |
| 218 | CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 219 | } |
| 220 | |
| 221 | /* Rulebase-id */ |
| 222 | { |
| 223 | /* |
| 224 | */ |
| 225 | struct dict_avp_data data = { |
| 226 | 5106, /* Code */ |
| 227 | 94, /* Vendor */ |
| 228 | "Rulebase-id", /* Name */ |
| 229 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 230 | AVP_FLAG_VENDOR, /* Fixed flag values */ |
| 231 | AVP_TYPE_OCTETSTRING /* base type of data */ |
| 232 | }; |
| 233 | CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL); |
| 234 | } |
| 235 | |
| 236 | /* Time-Of-First-Usage */ |
| 237 | { |
| 238 | /* |
| 239 | Time. Contains a time-stamp identifying the date |
| 240 | and time of the first increment of the used units |
| 241 | counter since the previous report. If no used units |
| 242 | were gathered during the previous reporting inter- |
| 243 | val, this AVP will not be present. |
| 244 | */ |
| 245 | struct dict_avp_data data = { |
| 246 | 5103, /* Code */ |
| 247 | 94, /* Vendor */ |
| 248 | "Time-Of-First-Usage", /* Name */ |
| 249 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 250 | AVP_FLAG_VENDOR, /* Fixed flag values */ |
| 251 | AVP_TYPE_OCTETSTRING /* base type of data */ |
| 252 | }; |
| 253 | CHECK_dict_new( DICT_AVP, &data , Time_type, NULL); |
| 254 | } |
| 255 | |
| 256 | /* Time-Of-Last-Usage */ |
| 257 | { |
| 258 | /* |
| 259 | Time. Contains a time-stamp identifying the date |
| 260 | and time of the first increment of the used units |
| 261 | counter since the previous report. If no used units |
| 262 | were gathered during the previous reporting inter- |
| 263 | val, this AVP will not be present. |
| 264 | */ |
| 265 | struct dict_avp_data data = { |
| 266 | 5104, /* Code */ |
| 267 | 94, /* Vendor */ |
| 268 | "Time-Of-Last-Usage", /* Name */ |
| 269 | AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, /* Fixed flags */ |
| 270 | AVP_FLAG_VENDOR, /* Fixed flag values */ |
| 271 | AVP_TYPE_OCTETSTRING /* base type of data */ |
| 272 | }; |
| 273 | CHECK_dict_new( DICT_AVP, &data , Time_type, NULL); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | TRACE_DEBUG(INFO, "Extension 'Dictionary definitions for DCCA Nokia' initialized"); |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | EXTENSION_ENTRY("dict_dcca_nokia", dict_dcca_nokia_entry, "dict_dcca"); |