Mercurial > hg > freeDiameter
comparison contrib/tools/org_to_fd.pl @ 1465:2f65b828eced
org_to_fd: add QoSFilterRule. improve error handling
author | Luke Mewburn <luke@mewburn.net> |
---|---|
date | Tue, 10 Mar 2020 09:50:10 +1100 |
parents | 4b613aaf8873 |
children |
comparison
equal
deleted
inserted
replaced
1464:1404de313b85 | 1465:2f65b828eced |
---|---|
22 | 22 |
23 sub base_type($) { | 23 sub base_type($) { |
24 my ($type) = @_; | 24 my ($type) = @_; |
25 | 25 |
26 return "AVP_TYPE_GROUPED" if ($type =~ m/Grouped/); | 26 return "AVP_TYPE_GROUPED" if ($type =~ m/Grouped/); |
27 return "AVP_TYPE_OCTETSTRING" if ($type =~ m/(Address|DiameterIdentity|DiameterURI|OctetString|IPFilterRule|Time|UTF8String)/); | 27 return "AVP_TYPE_OCTETSTRING" if ($type =~ m/(Address|DiameterIdentity|DiameterURI|OctetString|IPFilterRule|Time|UTF8String|QoSFilterRule)/); |
28 return "AVP_TYPE_INTEGER32" if ($type =~ m/Enumerated|Integer32/); | 28 return "AVP_TYPE_INTEGER32" if ($type =~ m/Enumerated|Integer32/); |
29 return "AVP_TYPE_INTEGER64" if ($type =~ m/Integer64/); | 29 return "AVP_TYPE_INTEGER64" if ($type =~ m/Integer64/); |
30 return "AVP_TYPE_UNSIGNED32" if ($type =~ m/Unsigned32/); | 30 return "AVP_TYPE_UNSIGNED32" if ($type =~ m/Unsigned32/); |
31 return "AVP_TYPE_UNSIGNED64" if ($type =~ m/Unsigned64/); | 31 return "AVP_TYPE_UNSIGNED64" if ($type =~ m/Unsigned64/); |
32 return "AVP_TYPE_FLOAT32" if ($type =~ m/Float32/); | 32 return "AVP_TYPE_FLOAT32" if ($type =~ m/Float32/); |
33 return "AVP_TYPE_FLOAT64" if ($type =~ m/Float64/); | 33 return "AVP_TYPE_FLOAT64" if ($type =~ m/Float64/); |
34 | 34 |
35 return "UNKNOWN TYPE: $type"; | 35 die("unknown type '$type'"); |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 my ($comment_width) = 64; | 39 my ($comment_width) = 64; |
40 | 40 |
65 | 65 |
66 print "\t\tCHECK_dict_new(DICT_AVP, &data, $avp_type, NULL);\n"; | 66 print "\t\tCHECK_dict_new(DICT_AVP, &data, $avp_type, NULL);\n"; |
67 } | 67 } |
68 | 68 |
69 sub usage($) { | 69 sub usage($) { |
70 die(sprintf("usage: %s [-V vendor_name] [-v vendor_code] [file ...]\n", $progname)); | 70 print STDERR "usage: $progname [-V vendor_name] [-v vendor_code] [file ...]\n"; |
71 exit(@_); | 71 exit(1); |
72 } | 72 } |
73 | 73 |
74 getopts("V:v:") || usage(1); | 74 getopts("V:v:") || usage(1); |
75 | 75 |
76 if (defined($opt_v)) { | 76 if (defined($opt_v)) { |
83 | 83 |
84 print_header(); | 84 print_header(); |
85 print_comment("Start of generated data."); | 85 print_comment("Start of generated data."); |
86 print_comment(""); | 86 print_comment(""); |
87 print_comment("The following is created automatically with:"); | 87 print_comment("The following is created automatically with:"); |
88 print_comment(sprintf(" org_to_fd.pl -V '%s' -v %s", $vendor_name, $vendor)); | 88 print_comment(" org_to_fd.pl -V '$vendor_name' -v $vendor"); |
89 print_comment("Changes will be lost during the next update."); | 89 print_comment("Changes will be lost during the next update."); |
90 print_comment("Do not modify; modify the source .org file instead."); | 90 print_comment("Do not modify; modify the source .org file instead."); |
91 print_header(); | 91 print_header(); |
92 print "\n"; | 92 print "\n"; |
93 | 93 |
103 print("\n"); | 103 print("\n"); |
104 next; | 104 next; |
105 } | 105 } |
106 | 106 |
107 if ($name =~ m/\s/) { | 107 if ($name =~ m/\s/) { |
108 die(sprintf("name '%s' contains space", $name)); | 108 die("name '$name' contains space"); |
109 } | 109 } |
110 | 110 |
111 my ($desc) = $name; | 111 my ($desc) = $name; |
112 $desc .= ", " . $type; | 112 $desc .= ", " . $type; |
113 $desc .= ", code " . $code; | 113 $desc .= ", code " . $code; |