| 1 |
SpeedDial Module |
| 2 |
|
| 3 |
Elena-Ramona Modroiu |
| 4 |
|
| 5 |
<[email protected]> |
| 6 |
|
| 7 |
Edited by |
| 8 |
|
| 9 |
Elena-Ramona Modroiu |
| 10 |
|
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Copyright © 2004 Voice Sistem SRL |
| 14 |
__________________________________________________________________ |
| 15 |
|
| 16 |
Table of Contents |
| 17 |
|
| 18 |
1. Admin Guide |
| 19 |
|
| 20 |
1. Overview |
| 21 |
2. Dependencies |
| 22 |
|
| 23 |
2.1. Kamailio Modules |
| 24 |
2.2. External Libraries or Applications |
| 25 |
|
| 26 |
3. Parameters |
| 27 |
|
| 28 |
3.1. db_url (string) |
| 29 |
3.2. user_column (string) |
| 30 |
3.3. domain_column (string) |
| 31 |
3.4. sd_user_column (string) |
| 32 |
3.5. sd_domain_column (string) |
| 33 |
3.6. new_uri_column (string) |
| 34 |
3.7. domain_prefix (string) |
| 35 |
3.8. use_domain (int) |
| 36 |
|
| 37 |
4. Functions |
| 38 |
|
| 39 |
4.1. sd_lookup(table [, owner]) |
| 40 |
|
| 41 |
5. Installation and Running |
| 42 |
|
| 43 |
5.1. Kamailio config file |
| 44 |
|
| 45 |
List of Examples |
| 46 |
|
| 47 |
1.1. Set db_url parameter |
| 48 |
1.2. Set user_column parameter |
| 49 |
1.3. Set domain_column parameter |
| 50 |
1.4. Set sd_user_column parameter |
| 51 |
1.5. Set sd_domain_column parameter |
| 52 |
1.6. Set new_uri_column parameter |
| 53 |
1.7. Set domain_prefix parameter |
| 54 |
1.8. Set use_domain parameter |
| 55 |
1.9. sd_lookup usage |
| 56 |
1.10. Kamailio config script - sample speeddial usage |
| 57 |
|
| 58 |
Chapter 1. Admin Guide |
| 59 |
|
| 60 |
Table of Contents |
| 61 |
|
| 62 |
1. Overview |
| 63 |
2. Dependencies |
| 64 |
|
| 65 |
2.1. Kamailio Modules |
| 66 |
2.2. External Libraries or Applications |
| 67 |
|
| 68 |
3. Parameters |
| 69 |
|
| 70 |
3.1. db_url (string) |
| 71 |
3.2. user_column (string) |
| 72 |
3.3. domain_column (string) |
| 73 |
3.4. sd_user_column (string) |
| 74 |
3.5. sd_domain_column (string) |
| 75 |
3.6. new_uri_column (string) |
| 76 |
3.7. domain_prefix (string) |
| 77 |
3.8. use_domain (int) |
| 78 |
|
| 79 |
4. Functions |
| 80 |
|
| 81 |
4.1. sd_lookup(table [, owner]) |
| 82 |
|
| 83 |
5. Installation and Running |
| 84 |
|
| 85 |
5.1. Kamailio config file |
| 86 |
|
| 87 |
1. Overview |
| 88 |
|
| 89 |
This module provides on-server speed dial facilities. A user can store |
| 90 |
records consisting of pairs short numbers (2 digits) and SIP addresses |
| 91 |
into a table of Kamailio. Then it can dial the two digits whenever it |
| 92 |
wants to call the SIP address associated with them. |
| 93 |
|
| 94 |
2. Dependencies |
| 95 |
|
| 96 |
2.1. Kamailio Modules |
| 97 |
2.2. External Libraries or Applications |
| 98 |
|
| 99 |
2.1. Kamailio Modules |
| 100 |
|
| 101 |
The following modules must be loaded before this module: |
| 102 |
* database module (mysql, dbtext, ...). |
| 103 |
|
| 104 |
2.2. External Libraries or Applications |
| 105 |
|
| 106 |
The following libraries or applications must be installed before |
| 107 |
running Kamailio with this module loaded: |
| 108 |
* None. |
| 109 |
|
| 110 |
3. Parameters |
| 111 |
|
| 112 |
3.1. db_url (string) |
| 113 |
3.2. user_column (string) |
| 114 |
3.3. domain_column (string) |
| 115 |
3.4. sd_user_column (string) |
| 116 |
3.5. sd_domain_column (string) |
| 117 |
3.6. new_uri_column (string) |
| 118 |
3.7. domain_prefix (string) |
| 119 |
3.8. use_domain (int) |
| 120 |
|
| 121 |
3.1. db_url (string) |
| 122 |
|
| 123 |
The URL of database where the table containing speed dial records. |
| 124 |
|
| 125 |
Default value is DEFAULT_RODB_URL. |
| 126 |
|
| 127 |
Example 1.1. Set db_url parameter |
| 128 |
... |
| 129 |
modparam("speeddial", "db_url", "mysql://kamailio:kamailiorw@localhost/kamailio" |
| 130 |
) |
| 131 |
... |
| 132 |
|
| 133 |
3.2. user_column (string) |
| 134 |
|
| 135 |
The name of column storing the user name of the owner of the speed dial |
| 136 |
record. |
| 137 |
|
| 138 |
Default value is “username”. |
| 139 |
|
| 140 |
Example 1.2. Set user_column parameter |
| 141 |
... |
| 142 |
modparam("speeddial", "user_column", "userid") |
| 143 |
... |
| 144 |
|
| 145 |
3.3. domain_column (string) |
| 146 |
|
| 147 |
The name of column storing the domain of the owner of the speed dial |
| 148 |
record. |
| 149 |
|
| 150 |
Default value is “domain”. |
| 151 |
|
| 152 |
Example 1.3. Set domain_column parameter |
| 153 |
... |
| 154 |
modparam("speeddial", "domain_column", "userdomain") |
| 155 |
... |
| 156 |
|
| 157 |
3.4. sd_user_column (string) |
| 158 |
|
| 159 |
The name of the column storing the user part of the short dial address. |
| 160 |
|
| 161 |
Default value is “sd_username”. |
| 162 |
|
| 163 |
Example 1.4. Set sd_user_column parameter |
| 164 |
... |
| 165 |
modparam("speeddial", "sd_user_column", "short_user") |
| 166 |
... |
| 167 |
|
| 168 |
3.5. sd_domain_column (string) |
| 169 |
|
| 170 |
The name of the column storing the domain of the short dial address. |
| 171 |
|
| 172 |
Default value is “sd_domain”. |
| 173 |
|
| 174 |
Example 1.5. Set sd_domain_column parameter |
| 175 |
... |
| 176 |
modparam("speeddial", "sd_domain_column", "short_domain") |
| 177 |
... |
| 178 |
|
| 179 |
3.6. new_uri_column (string) |
| 180 |
|
| 181 |
The name of the column containing the URI that will be use to replace |
| 182 |
the short dial URI. |
| 183 |
|
| 184 |
Default value is “new_uri”. |
| 185 |
|
| 186 |
Example 1.6. Set new_uri_column parameter |
| 187 |
... |
| 188 |
modparam("speeddial", "new_uri_column", "real_uri") |
| 189 |
... |
| 190 |
|
| 191 |
3.7. domain_prefix (string) |
| 192 |
|
| 193 |
If the domain of the owner (From URI) starts with the value of this |
| 194 |
parameter, then it is stripped before performing the lookup of the |
| 195 |
short number. |
| 196 |
|
| 197 |
Default value is NULL. |
| 198 |
|
| 199 |
Example 1.7. Set domain_prefix parameter |
| 200 |
... |
| 201 |
modparam("speeddial", "domain_prefix", "tel.") |
| 202 |
... |
| 203 |
|
| 204 |
3.8. use_domain (int) |
| 205 |
|
| 206 |
The parameter specifies whether or not to use the domain when searching |
| 207 |
a speed dial record (0 - no domain, 1 - use domain from From URI, 2 - |
| 208 |
use both domains, from From URI and from request URI). |
| 209 |
|
| 210 |
Default value is 0. |
| 211 |
|
| 212 |
Example 1.8. Set use_domain parameter |
| 213 |
... |
| 214 |
modparam("speeddial", "use_domain", 1) |
| 215 |
... |
| 216 |
|
| 217 |
4. Functions |
| 218 |
|
| 219 |
4.1. sd_lookup(table [, owner]) |
| 220 |
|
| 221 |
4.1. sd_lookup(table [, owner]) |
| 222 |
|
| 223 |
The function lookups the short dial number from R-URI in 'table' and |
| 224 |
replaces the R-URI with associated address. |
| 225 |
|
| 226 |
Meaning of the parameters is as follows: |
| 227 |
* table - The name of the table storing the speed dial records. |
| 228 |
* owner - The SIP URI of the owner of short dialing codes. If not |
| 229 |
present, URI of From header is used. |
| 230 |
|
| 231 |
This function can be used from REQUEST_ROUTE. |
| 232 |
|
| 233 |
Example 1.9. sd_lookup usage |
| 234 |
... |
| 235 |
# 'speed_dial' is the default table name created by kamailio db script |
| 236 |
if(uri=~"sip:[0-9]{2}@.*") |
| 237 |
sd_lookup("speed_dial"); |
| 238 |
# use auth username |
| 239 |
if(uri=~"sip:[0-9]{2}@.*") |
| 240 |
sd_lookup("speed_dial", "sip:$au@$fd"); |
| 241 |
... |
| 242 |
|
| 243 |
5. Installation and Running |
| 244 |
|
| 245 |
5.1. Kamailio config file |
| 246 |
|
| 247 |
5.1. Kamailio config file |
| 248 |
|
| 249 |
Next picture displays a sample usage of speeddial. |
| 250 |
|
| 251 |
Example 1.10. Kamailio config script - sample speeddial usage |
| 252 |
... |
| 253 |
# |
| 254 |
# sample config script to use speeddial module |
| 255 |
# |
| 256 |
|
| 257 |
# ----------- global configuration parameters ------------------------ |
| 258 |
|
| 259 |
check_via=no # (cmd. line: -v) |
| 260 |
dns=no # (cmd. line: -r) |
| 261 |
rev_dns=no # (cmd. line: -R) |
| 262 |
|
| 263 |
# ------------------ module loading ---------------------------------- |
| 264 |
|
| 265 |
loadmodule "sl.so" |
| 266 |
loadmodule "tm.so" |
| 267 |
loadmodule "rr.so" |
| 268 |
loadmodule "maxfwd.so" |
| 269 |
loadmodule "usrloc.so" |
| 270 |
loadmodule "registrar.so" |
| 271 |
loadmodule "textops.so" |
| 272 |
loadmodule "mysql.so" |
| 273 |
loadmodule "speeddial.so" |
| 274 |
loadmodule "jsonrpcs.so" |
| 275 |
|
| 276 |
# ----------------- setting module-specific parameters --------------- |
| 277 |
|
| 278 |
# -- usrloc params -- |
| 279 |
|
| 280 |
modparam("usrloc", "db_mode", 0) |
| 281 |
|
| 282 |
# -- rr params -- |
| 283 |
# add value to ;lr param to make some broken UAs happy |
| 284 |
modparam("rr", "enable_full_lr", 1) |
| 285 |
|
| 286 |
# ------------------------- request routing logic ------------------- |
| 287 |
|
| 288 |
# main routing logic |
| 289 |
route{ |
| 290 |
|
| 291 |
# initial sanity checks |
| 292 |
if (!mf_process_maxfwd_header("10")) |
| 293 |
{ |
| 294 |
sl_send_reply("483","Too Many Hops"); |
| 295 |
exit; |
| 296 |
}; |
| 297 |
|
| 298 |
if (!method=="REGISTER") record_route(); |
| 299 |
|
| 300 |
if (loose_route()) |
| 301 |
{ |
| 302 |
if (!t_relay()) |
| 303 |
{ |
| 304 |
sl_reply_error(); |
| 305 |
}; |
| 306 |
exit; |
| 307 |
}; |
| 308 |
|
| 309 |
if (!uri==myself) |
| 310 |
{ |
| 311 |
if (!t_relay()) |
| 312 |
{ |
| 313 |
sl_reply_error(); |
| 314 |
}; |
| 315 |
exit; |
| 316 |
}; |
| 317 |
|
| 318 |
if (uri==myself) |
| 319 |
{ |
| 320 |
if (method=="REGISTER") |
| 321 |
{ |
| 322 |
save("location"); |
| 323 |
exit; |
| 324 |
}; |
| 325 |
|
| 326 |
if(uri=~"sip:[0-9]{2}@.*") |
| 327 |
sd_lookup("speeddial"); |
| 328 |
|
| 329 |
lookup("aliases"); |
| 330 |
if (!uri==myself) |
| 331 |
{ |
| 332 |
if (!t_relay()) |
| 333 |
{ |
| 334 |
sl_reply_error(); |
| 335 |
}; |
| 336 |
exit; |
| 337 |
}; |
| 338 |
|
| 339 |
if (!lookup("location")) |
| 340 |
{ |
| 341 |
sl_send_reply("404", "Not Found"); |
| 342 |
exit; |
| 343 |
}; |
| 344 |
}; |
| 345 |
|
| 346 |
if (!t_relay()) |
| 347 |
{ |
| 348 |
sl_reply_error(); |
| 349 |
}; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
... |