| 1 |
IMS Diameter Server Module |
| 2 |
|
| 3 |
Carsten Bock |
| 4 |
|
| 5 |
ng-voice GmbH |
| 6 |
|
| 7 |
Copyright © 2016-2017 ng-voice GmbH |
| 8 |
__________________________________________________________________ |
| 9 |
|
| 10 |
Table of Contents |
| 11 |
|
| 12 |
1. Admin Guide |
| 13 |
|
| 14 |
1. Overview |
| 15 |
2. Dependencies |
| 16 |
|
| 17 |
2.1. Kamailio Modules |
| 18 |
2.2. External Libraries or Applications |
| 19 |
|
| 20 |
3. Functions |
| 21 |
|
| 22 |
3.1. diameter_request([peer], appid, commandcode, message) |
| 23 |
3.2. diameter_request_async([peer], appid, commandcode, |
| 24 |
message) |
| 25 |
|
| 26 |
4. Exported Pseudo Variables |
| 27 |
|
| 28 |
4.1. $diameter_application |
| 29 |
4.2. $diameter_command |
| 30 |
4.3. $diameter_request |
| 31 |
4.4. $diameter_response |
| 32 |
|
| 33 |
5. Event routes |
| 34 |
|
| 35 |
5.1. diameter:request |
| 36 |
5.2. diameter:response |
| 37 |
|
| 38 |
List of Examples |
| 39 |
|
| 40 |
1.1. diameter_request usage |
| 41 |
|
| 42 |
Chapter 1. Admin Guide |
| 43 |
|
| 44 |
Table of Contents |
| 45 |
|
| 46 |
1. Overview |
| 47 |
2. Dependencies |
| 48 |
|
| 49 |
2.1. Kamailio Modules |
| 50 |
2.2. External Libraries or Applications |
| 51 |
|
| 52 |
3. Functions |
| 53 |
|
| 54 |
3.1. diameter_request([peer], appid, commandcode, message) |
| 55 |
3.2. diameter_request_async([peer], appid, commandcode, message) |
| 56 |
|
| 57 |
4. Exported Pseudo Variables |
| 58 |
|
| 59 |
4.1. $diameter_application |
| 60 |
4.2. $diameter_command |
| 61 |
4.3. $diameter_request |
| 62 |
4.4. $diameter_response |
| 63 |
|
| 64 |
5. Event routes |
| 65 |
|
| 66 |
5.1. diameter:request |
| 67 |
5.2. diameter:response |
| 68 |
|
| 69 |
1. Overview |
| 70 |
|
| 71 |
This module implements a generic Diameter Server. |
| 72 |
|
| 73 |
This module translates incoming Diameter Messages into a JSON structure |
| 74 |
and will pass this on to the routing engine for further operations. |
| 75 |
|
| 76 |
The module expects a reply (again in JSON), which then is translated |
| 77 |
into a Diameter Response. |
| 78 |
|
| 79 |
Additionally, it allows you to send Diameter-Requests to another peer. |
| 80 |
|
| 81 |
The JSON contains an array with all AVP's in the Diameter-Message and |
| 82 |
its attributes. The format is identical for both requests and replies. |
| 83 |
[ |
| 84 |
{ |
| 85 |
"avpCode":277, |
| 86 |
"vendorId":0, |
| 87 |
"Flags":64, |
| 88 |
"int32":0 |
| 89 |
}, |
| 90 |
{ |
| 91 |
"avpCode":260, |
| 92 |
"vendorId":0, |
| 93 |
"Flags":64, |
| 94 |
"list":[ |
| 95 |
{ |
| 96 |
"avpCode":266, |
| 97 |
"vendorId":0, |
| 98 |
"Flags":64, |
| 99 |
"int32":10415 |
| 100 |
}, |
| 101 |
{ |
| 102 |
"avpCode":258, |
| 103 |
"vendorId":0, |
| 104 |
"Flags":64, |
| 105 |
"int32":16777216 |
| 106 |
} |
| 107 |
] |
| 108 |
}, |
| 109 |
{ |
| 110 |
"avpCode":1, |
| 111 |
"vendorId":0, |
| 112 |
"Flags":64, |
| 113 |
"string":"[email protected]" |
| 114 |
}, |
| 115 |
{ |
| 116 |
"avpCode":618, |
| 117 |
"vendorId":10415, |
| 118 |
"Flags":64, |
| 119 |
"list":[ |
| 120 |
{ |
| 121 |
"avpCode":621, |
| 122 |
"vendorId":10415, |
| 123 |
"Flags":64, |
| 124 |
"string":"pcscf.kamailio.org" |
| 125 |
} |
| 126 |
] |
| 127 |
}, |
| 128 |
{ |
| 129 |
"avpCode":268, |
| 130 |
"vendorId":0, |
| 131 |
"Flags":64, |
| 132 |
"int32":2001 |
| 133 |
} |
| 134 |
] |
| 135 |
|
| 136 |
The module could be used (for example) for: |
| 137 |
* a Home-Subscriber-Server (it was written do be used as one) |
| 138 |
* a Charging-Server (Ro/Rf) |
| 139 |
* for testing Diameter-Applications |
| 140 |
* a PCRF/PCEF Emulator/Gateway |
| 141 |
* a Diameter-Routing-Agent (DRA) |
| 142 |
* ... |
| 143 |
|
| 144 |
2. Dependencies |
| 145 |
|
| 146 |
2.1. Kamailio Modules |
| 147 |
2.2. External Libraries or Applications |
| 148 |
|
| 149 |
2.1. Kamailio Modules |
| 150 |
|
| 151 |
The following modules must be loaded before this module: |
| 152 |
* CDP - C Diameter Peer |
| 153 |
* CDP_AVP - CDP AVP Applications |
| 154 |
|
| 155 |
2.2. External Libraries or Applications |
| 156 |
|
| 157 |
No external libraries are required. |
| 158 |
|
| 159 |
3. Functions |
| 160 |
|
| 161 |
3.1. diameter_request([peer], appid, commandcode, message) |
| 162 |
3.2. diameter_request_async([peer], appid, commandcode, message) |
| 163 |
|
| 164 |
3.1. diameter_request([peer], appid, commandcode, message) |
| 165 |
|
| 166 |
This method will send a Diameter Request. |
| 167 |
|
| 168 |
Meaning of the parameters is as follows: |
| 169 |
* peer - send the diameter request directly to a diameter peer |
| 170 |
[optional]. If this parameter is omitted, the default routing is |
| 171 |
used (see CDP). |
| 172 |
* appid - Diameter-Application, e.g.: |
| 173 |
Typical App-ID's are: |
| 174 |
+ 16777216 - Diameter Cx/Dx |
| 175 |
+ 16777217 - Diameter Sh |
| 176 |
+ 4 - Diameter Ro (Online Charging) |
| 177 |
+ ... |
| 178 |
* commandcode - Diameter-Command-Code, e.g.: |
| 179 |
+ 300 - Diameter Cx/Dx User-Assignment Request (UAR) |
| 180 |
+ 301 - Diameter Cx/Dx Server-Assignment Request (SAR) |
| 181 |
+ ... |
| 182 |
* message - the Diameter Message (as JSON), which should be sent. |
| 183 |
|
| 184 |
This function can be used from any route. |
| 185 |
|
| 186 |
Example 1.1. diameter_request usage |
| 187 |
... |
| 188 |
diameter_request("16777216", "300", "{ some json }"); |
| 189 |
... |
| 190 |
|
| 191 |
3.2. diameter_request_async([peer], appid, commandcode, message) |
| 192 |
|
| 193 |
This method will send a Diameter Request asynchronously. The Reply to |
| 194 |
this request will be visible in the event-route "diameter:response". |
| 195 |
|
| 196 |
The meaning of the parameters are identical to the diameter_request |
| 197 |
function. |
| 198 |
|
| 199 |
This function is only available, if the diameter:response event-route |
| 200 |
is defined. |
| 201 |
|
| 202 |
4. Exported Pseudo Variables |
| 203 |
|
| 204 |
4.1. $diameter_application |
| 205 |
4.2. $diameter_command |
| 206 |
4.3. $diameter_request |
| 207 |
4.4. $diameter_response |
| 208 |
|
| 209 |
4.1. $diameter_application |
| 210 |
|
| 211 |
This PV provides the requested Diameter Application, for example: |
| 212 |
* 16777216 - Diameter Cx/Dx |
| 213 |
* 16777217 - Diameter Sh |
| 214 |
* 4 - Diameter Ro (Online Charging) |
| 215 |
* ... |
| 216 |
|
| 217 |
4.2. $diameter_command |
| 218 |
|
| 219 |
This PV provides the requested Diameter Command, for example: |
| 220 |
* 300 - Diameter Cx/Dx User-Assignment Request (UAR) |
| 221 |
* 301 - Diameter Cx/Dx Server-Assignment Request (SAR) |
| 222 |
* ... |
| 223 |
|
| 224 |
4.3. $diameter_request |
| 225 |
|
| 226 |
This PV provides the Diameter Request as JSON. |
| 227 |
|
| 228 |
4.4. $diameter_response |
| 229 |
|
| 230 |
The Response is read from the PVAR. |
| 231 |
|
| 232 |
5. Event routes |
| 233 |
|
| 234 |
5.1. diameter:request |
| 235 |
5.2. diameter:response |
| 236 |
|
| 237 |
5.1. diameter:request |
| 238 |
|
| 239 |
This route is called for any incoming Diameter Request |
| 240 |
... |
| 241 |
event_route[diameter:request] { |
| 242 |
$var(res) = http_connect("hss", "/application/$diameter_application/comm |
| 243 |
and/$diameter_command", "application/json", "$diameter_request", "$var(response) |
| 244 |
"); |
| 245 |
if ($var(res) == 200) { |
| 246 |
$diameter_response = $var(response); |
| 247 |
} |
| 248 |
} |
| 249 |
... |
| 250 |
|
| 251 |
5.2. diameter:response |
| 252 |
|
| 253 |
This route is called for incoming Diameter replies, if the request was |
| 254 |
processed asynchronously. |
| 255 |
... |
| 256 |
event_route[diameter:response] { |
| 257 |
xlog("Reply to Diameter request $diameter_request is $diameter_response\ |
| 258 |
n"); |
| 259 |
} |
| 260 |
... |