| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include <freeDiameter/extension.h> |
| 5 |
|
| 6 |
|
| 7 |
|
| 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 |
|
| 64 |
{ |
| 65 |
|
| 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 |
|
| 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 |
|
| 89 |
{ |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
struct dict_avp_data data = { |
| 102 |
5113, |
| 103 |
94, |
| 104 |
"NSN-Token-Value", |
| 105 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 106 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 107 |
AVP_TYPE_OCTETSTRING |
| 108 |
}; |
| 109 |
CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
{ |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
struct dict_avp_data data = { |
| 132 |
5109, |
| 133 |
94, |
| 134 |
"Quota-Consumption-Time", |
| 135 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 136 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 137 |
AVP_TYPE_UNSIGNED32 |
| 138 |
}; |
| 139 |
CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
{ |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
struct dict_avp_data data = { |
| 163 |
5110, |
| 164 |
94, |
| 165 |
"Quota-Holding-Time", |
| 166 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 167 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 168 |
AVP_TYPE_UNSIGNED32 |
| 169 |
}; |
| 170 |
CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
{ |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
struct dict_avp_data data = { |
| 191 |
5111, |
| 192 |
94, |
| 193 |
"Default-Quota", |
| 194 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 195 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 196 |
AVP_TYPE_GROUPED |
| 197 |
}; |
| 198 |
CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
{ |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
struct dict_avp_data data = { |
| 211 |
5105, |
| 212 |
94, |
| 213 |
"Session-Start-Indicator", |
| 214 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 215 |
AVP_FLAG_VENDOR, |
| 216 |
AVP_TYPE_OCTETSTRING |
| 217 |
}; |
| 218 |
CHECK_dict_new( DICT_AVP, &data , NULL, NULL); |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
{ |
| 223 |
|
| 224 |
|
| 225 |
struct dict_avp_data data = { |
| 226 |
5106, |
| 227 |
94, |
| 228 |
"Rulebase-id", |
| 229 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 230 |
AVP_FLAG_VENDOR, |
| 231 |
AVP_TYPE_OCTETSTRING |
| 232 |
}; |
| 233 |
CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL); |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
{ |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
struct dict_avp_data data = { |
| 246 |
5103, |
| 247 |
94, |
| 248 |
"Time-Of-First-Usage", |
| 249 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 250 |
AVP_FLAG_VENDOR, |
| 251 |
AVP_TYPE_OCTETSTRING |
| 252 |
}; |
| 253 |
CHECK_dict_new( DICT_AVP, &data , Time_type, NULL); |
| 254 |
} |
| 255 |
|
| 256 |
|
| 257 |
{ |
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
struct dict_avp_data data = { |
| 266 |
5104, |
| 267 |
94, |
| 268 |
"Time-Of-Last-Usage", |
| 269 |
AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, |
| 270 |
AVP_FLAG_VENDOR, |
| 271 |
AVP_TYPE_OCTETSTRING |
| 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"); |