/modules/osp/etc/sample-osp-opensips.cfg

https://bitbucket.org/viraptor/opensips-mirror · Config · 738 lines · 647 code · 91 blank · 0 comment · 0 complexity · a540b7aae5c42fea62d839f84024b010 MD5 · raw file

  1. debug=3 # debug level (cmd line: -dddddddddd)
  2. fork=yes
  3. log_stderror=no # (cmd line: -E)
  4. sip_warning=no
  5. /* Uncomment these lines to enter debugging mode
  6. # fork=no
  7. # log_stderror=yes
  8. */
  9. check_via=no # (cmd. line: -v)
  10. dns=no # (cmd. line: -r)
  11. rev_dns=no # (cmd. line: -R)
  12. disable_dns_blacklist=yes
  13. disable_tcp=yes
  14. disable_tls=yes
  15. port=5060
  16. children=20
  17. # --------- AVP aliases ----------------------------------------------
  18. avp_aliases="srcdev=i:1"
  19. avp_aliases="snid=i:2"
  20. avp_aliases="cinfo=i:3"
  21. avp_aliases="from=i:10"
  22. # --------- module loading -------------------------------------------
  23. mpath="/usr/local/lib/opensips/modules"
  24. loadmodule "sl.so"
  25. loadmodule "tm.so"
  26. loadmodule "maxfwd.so"
  27. loadmodule "rr.so"
  28. loadmodule "textops.so"
  29. loadmodule "usrloc.so"
  30. loadmodule "signaling.so"
  31. loadmodule "registrar.so"
  32. loadmodule "auth.so"
  33. loadmodule "mi_fifo.so"
  34. loadmodule "options.so"
  35. loadmodule "xlog.so"
  36. loadmodule "avpops.so"
  37. # Load OSP module
  38. loadmodule "osp.so"
  39. # For SIP From header modification
  40. # loadmodule "uac.so"
  41. # --------- setting module-specific parameters -----------------------
  42. #
  43. # PEERING PARAMETERS
  44. # ====================================================================
  45. # This section contains configuration parameters that enables OpenSIPS
  46. # to communicate with one or more OSP servers for routing and CDR
  47. # collection. The parameter sp1_uri must be configured. Additional
  48. # detail on OSP Module parameters and functions is provided in the
  49. # "OSP Module for Secure, Multi-Lateral Peering" document located at
  50. # http://www.opensips.org/html/docs/modules/devel/osp.html
  51. #
  52. #
  53. # Configure Work Mode
  54. # ====================================================================
  55. # This parameter is used to tell the OSP module the work mode it
  56. # should work in. The default value is 0.
  57. #
  58. # 0 - Direct
  59. # 1 - Indirect
  60. #
  61. # modparam("osp", "work_mode", 0)
  62. #
  63. # Configure Service Type
  64. # ====================================================================
  65. # This parameter is used to tell the OSP module the service type it
  66. # should provide. The default value is 0.
  67. #
  68. # 0 - Normal voice service
  69. # 1 - Ported number query service
  70. #
  71. # modparam("osp", "service_type", 0)
  72. #
  73. # Configure OSP Servers
  74. # ====================================================================
  75. # OpenSIPS can be configured to query up to 16 OSP servers for routing
  76. # information, number portability correction and peering authorization
  77. # tokens using the sp1_uri to sp16_uri parameters. Each spX_uri is
  78. # the configuration for an OSP server. A configuration for sp1_uri
  79. # is required. Configuring other OSP servers, using sp2_uri, ...,
  80. # sp16_uri parameters, is optional. The OSP server address should be
  81. # configured as a standard URL beginning with either http:// or
  82. # https:// followed by the domain name of the OSP server or the IP
  83. # address enclosed in brackets. The domain name or IP address should
  84. # be followed by the peering server TCP port number and uniform
  85. # resource identifier. Below are example configurations.
  86. #
  87. modparam("osp", "sp1_uri", "http://osptestserver.transnexus.com:5045/osp")
  88. # modparam("osp", "sp2_uri", "https://[1.2.3.4]:1443/osp")
  89. #
  90. # OpenSIPS IP Address
  91. # ====================================================================
  92. # device_ip is a recommended parameter that explicitly defines the IP
  93. # address of OpenSIPS in an OSP AuthorizationRequest message (as
  94. # SourceAlternate type=transport). The IP address must be in brackets
  95. # as shown in the example below.
  96. #
  97. # modparam("osp", "device_ip", "[127.0.0.1]:5060")
  98. #
  99. # Use OSP Security Features
  100. # ====================================================================
  101. # This parameter is used to tell the OSP module if the OSP security
  102. # features should be used. The default value is 0.
  103. #
  104. # 0 - OSP module will not use the OSP security features.
  105. # 1 - OSP module will use the OSP security features.
  106. #
  107. # modparam("osp", "use_security_features", 0)
  108. #
  109. # Peering Token Validation
  110. # ====================================================================
  111. # When OpenSIPS receives a SIP INVITE with an OSP peering token, the
  112. # OSP Module will validate the token to determine whether or not the
  113. # call has been authorized by a trusted OSP server. OSP peering
  114. # tokens may, or may not, be digitally signed. This parameter defines
  115. # if OpenSIPS will validate signed or unsigned tokens or both. The
  116. # values for "token format" are defined below. The default value
  117. # is 2. If the use_security_features parameter is set to 0, signed
  118. # tokens cannot be validated.
  119. #
  120. # 0 - Validate only signed tokens. Calls with valid signed tokens are
  121. # allowed.
  122. # 1 - Validate only unsigned tokens. Calls with valid unsigned tokens
  123. # are allowed.
  124. # 2 - Validate both signed and unsigned tokens are allowed. Calls
  125. # with valid tokens are allowed.
  126. #
  127. # modparam("osp", "token_format", 2)
  128. #
  129. # Crypto files from Peering Server Enrollment
  130. # ====================================================================
  131. # These parameters identify crypto files used for validating peering
  132. # authorization tokens and establishing a secure channel between
  133. # OpenSIPS and an OSP server using SSL. The files may be generated
  134. # using the 'Enroll' utility from the OSP Toolkit. By default, the
  135. # proxy will look for pkey.pem, localcert.pem, and cacart_0.pem in the
  136. # default configuration directory.
  137. #
  138. # The default config directory is set at compile time using CFG_DIR
  139. # and defaults to /usr/local/etc/opensips/. The files may be copied
  140. # to the expected file location or the parameters below may be
  141. # changed. If the use_security_features parameter is set to 0, these
  142. # parameters will be ignored.
  143. #
  144. # If the default CFG_DIR value was used at compile time, the files
  145. # will be loaded from:
  146. # modparam("osp", "private_key", "/usr/local/etc/opensips/pkey.pem")
  147. # modparam("osp", "local_certificate", "/usr/local/etc/opensips/localcert.pem")
  148. # modparam("osp", "ca_certificates", "/usr/local/etc/opensips/cacert_0.pem")
  149. #
  150. # Use Remote-Party-ID for calling number
  151. # ====================================================================
  152. # This parameter is used to tell the OSP module if the calling number
  153. # should be obtained from RPID header. The default value is 1.
  154. #
  155. # 0 - OSP module will use the calling number in From header.
  156. # 1 - OSP module will use the calling number in RPID header if a RPID
  157. # header exists.
  158. #
  159. # modparam("osp", "use_rpid_for_calling_number", 1)
  160. #
  161. # Use Number Portability parameters
  162. # ====================================================================
  163. # This parameter is used to tell the OSP module if the number
  164. # portability parameters should be obtained from RURI. The default
  165. # value is 1.
  166. #
  167. # 0 - OSP module will not use the number portability parameters.
  168. # 1 - OSP module will use the number portability parameters in RURI in
  169. # Authorization Request to OSP server if these parameters exist in
  170. # the INVITE received from the UA.
  171. #
  172. # modparam("osp", "use_number_portability", 1)
  173. #
  174. # URI Format for Redirection Messages
  175. # ====================================================================
  176. # This parameter is used to tell the OSP module which URI format
  177. # should be used for SIP redirect messages. The default value is 0.
  178. #
  179. # 0 - "xxxxxxxxxx@xxx.xxx.xxx.xxx"
  180. # 1 - "<xxxxxxxxxx@xxx.xxx.xxx.xxx>". (For Cisco 2600 IP-IP gateway)
  181. #
  182. # modparam("osp", "redirection_uri_format", 0)
  183. #
  184. # Append "user=phone" Parameter
  185. # ====================================================================
  186. # This parameter is used to tell the OSP module if the "user=phone"
  187. # parameter, which indicates that the user portion of the URI should
  188. # be treated as a tel URI, should be appended. The default value is
  189. # 0.
  190. #
  191. # modparam("osp", "append_userphone", 0)
  192. #
  193. # Append Destination Network ID
  194. # ====================================================================
  195. # This parameter is used to tell the OSP module if destination
  196. # network ID should be appended. If it is set to 0, network ID is not
  197. # appended in outbound destination URIs. If it is set to 1, network ID
  198. # is appended. The default value is 1.
  199. #
  200. # modparam("osp", "append_networkid", 1)
  201. #
  202. # Source Device IP AVP
  203. # ====================================================================
  204. # This parameter is used to tell the OSP module which AVP is used to
  205. # store source device IP in the indirect work mode. The default
  206. # value is "$avp(s:_osp_source_device_)".
  207. #
  208. # modparam("osp", "source_device_avp", "$avp(s:_osp_source_device_)")
  209. modparam("osp", "source_device_avp", "$avp(srcdev)")
  210. #
  211. # Source Network ID AVP
  212. # ====================================================================
  213. # This parameter is used to tell the OSP module which AVP is used to
  214. # store source network ID. The default value is
  215. # "$avp(s:_osp_source_networkid_)".
  216. #
  217. # modparam("osp", "source_networkid_avp", "$avp(s:_osp_source_networkid_)")
  218. modparam("osp", "source_networkid_avp", "$avp(snid)")
  219. #
  220. # Custom Information AVP
  221. # ====================================================================
  222. # This parameter is used to tell the OSP module which AVP is used to
  223. # store custom information. The default value is
  224. # "$avp(s:_osp_custom_info_)".
  225. #
  226. # modparam("osp", "custom_info_avp", "$avp(s:_osp_custom_info_)")
  227. modparam("osp", "custom_info_avp", "$avp(cinfo)")
  228. #
  229. # -- mi_fifo params --
  230. #
  231. # The name of the FIFO file to be created for listening and reading
  232. # external commands.
  233. #
  234. modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
  235. # -- usrloc params --
  236. #
  237. # Disable the usrloc module to utilize database for persistent
  238. # contact storage.
  239. #
  240. modparam("usrloc", "db_mode", 0)
  241. # -- rr params --
  242. #
  243. # Use ";lr=on" instead of ";lr". This is to overcome problems with
  244. # broken UAs which strip ";lr" parameter when generating Route header
  245. # fields from Record-Route.
  246. #
  247. modparam("rr", "enable_full_lr", 1)
  248. #
  249. # Enable append_fromtag, request's from-tag is appended to
  250. # Record-Route. This is useful for understanding whether subsequent
  251. # requests (such as BYE) come from caller (route's from-tag==BYE's
  252. # from-tag) or callee (route's from-tag==BYE's to-tag).
  253. #
  254. modparam("rr", "append_fromtag", 1)
  255. # -- tm params --
  256. #
  257. # Timer which hits if there is no response (including provisional
  258. # messages such as 100, 180, 183, ..., etc.) for a request such as
  259. # INVITE, RE-INVITE or BYE after fr_timer seconds.
  260. #
  261. # For the INVITE use case, if the proxy does not receive a response
  262. # to an INVITE before this timer expires, the proxy will retry the
  263. # call and send an INVITE to the next VoIP destination in the routing
  264. # list.
  265. #
  266. # For the RE-INVITE and BYE use cases, if the proxy does not receive
  267. # a response before this timer expires, the proxy will send a SIP 408
  268. # Timeout message to the source of the request.
  269. #
  270. modparam("tm", "fr_timer", 2)
  271. #
  272. # Timer which hits if no final reply for an INVITE arrives after a
  273. # provisional message was received (in seconds). For example, user is
  274. # not picking up the phone.
  275. #
  276. modparam("tm", "fr_inv_timer", 300)
  277. # --------- request routing logic ------------------------------------
  278. # main routing logic
  279. route{
  280. xlog("L_INFO", "----ROUTE: Route IN - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
  281. # initial sanity checks
  282. if (!mf_process_maxfwd_header("10")) {
  283. xlog("L_WARN", "----ROUTE: Too many hops, $rm from '$fu' to '$tu'\n");
  284. sl_send_reply("483", "Too Many Hops");
  285. return;
  286. };
  287. if (msg:len >= max_len) {
  288. xlog("L_WARN", "----ROUTE: Message too big, $rm from '$fu' to '$tu'\n");
  289. sl_send_reply("513", "Message Too Big");
  290. return;
  291. };
  292. # we record-route all messages -- to make sure that
  293. # subsequent messages will go through our proxy; this
  294. # is useful if upstream and downstream entities
  295. # use different transport protocol
  296. record_route();
  297. # loose-route processing
  298. if (loose_route()) {
  299. if (method=="INVITE") {
  300. log(2, "----ROUTE: Relay re-INVITE\n");
  301. # send it out now; use stateful forwarding as it works
  302. # reliably even for UDP2TCP
  303. if (!t_relay()) {
  304. sl_reply_error();
  305. }
  306. return;
  307. } else if (method=="ACK") {
  308. log(2, "----ROUTE: Relay ACK\n");
  309. # send it out now; use stateful forwarding as it works
  310. # reliably even for UDP2TCP
  311. if (!t_relay()) {
  312. sl_reply_error();
  313. }
  314. return;
  315. }
  316. } else {
  317. if (method=="BYE") {
  318. xlog("L_WARN", "----ROUTE: Processing BYE without route header - F=$fu T=$tu IP=$si ID=$ci\n");
  319. if (t_check_trans()) {
  320. log(2, "----ROUTE: Duplicated BYE\n");
  321. } else {
  322. # NOTE - don't t_relay before reporting usage
  323. if (is_direction("downstream")) {
  324. log(2, "----ROUTE: BYE from SOURCE\n");
  325. if (!reportospusage("0")) {
  326. xlog("L_WARN", "----ROUTE: failed to report usage, from '$fu' to '$tu'\n");
  327. }
  328. } else {
  329. log(2, "----ROUTE: BYE from DESTINATION\n");
  330. if (!reportospusage("1")) {
  331. xlog("L_WARN", "----ROUTE: failed to report usage, from '$fu' to '$tu'\n");
  332. }
  333. }
  334. sl_send_reply("400", "Bad Request - no route header in BYE message");
  335. }
  336. return;
  337. }
  338. }
  339. if (method=="INVITE") {
  340. log(2, "----ROUTE: Processing INVITE\n");
  341. # Stop retransmission
  342. sl_send_reply("100", "Trying");
  343. if (t_check_trans()) {
  344. log(2, "----ROUTE: Duplicated INVITE\n");
  345. return;
  346. }
  347. # Authentication
  348. log(3, "OSP authorization validation logic\n");
  349. if ($hdr(P-Source-Device) != NULL) {
  350. $avp(srcdev) = $hdr(P-Source-Device);
  351. }
  352. # This function looks for OSP peering token in the message.
  353. # It will fail if the token is not present
  354. if (checkospheader()) {
  355. log(3, "With OSP token, validate it\n");
  356. # The function validates OSP tokens. It will fail if the
  357. # token is not valid or has expired
  358. validateospheader();
  359. switch ($retcode) {
  360. case 1:
  361. # Authorization is valid. The proxy can now use
  362. # its own database of registered users for
  363. # routing information.
  364. # The proxy could also issue another OSP peering
  365. # authorization and routing request by calling
  366. # route(1) function.
  367. log(3, "OSP authorization valid\n");
  368. # Remove the OSP peering token from the received
  369. # message otherwise it will be forwarded on to
  370. # the next hop
  371. remove_hf("P-OSP-Auth-Token");
  372. break;
  373. case -2:
  374. log(2, "----ROUTE: Internal server error\n");
  375. sl_send_reply("500", "Internal Server Error");
  376. return;
  377. default:
  378. log(2, "----ROUTE: OSP authorization invalid\n");
  379. sl_send_reply("401", "Unauthorized");
  380. return;
  381. };
  382. } else {
  383. log(3, "Without OSP token, apply different authentication strategy\n");
  384. log(3, "Go ahead, everyone is welcomed\n");
  385. # Implement authentication strategy here or simply add the
  386. # statements below to block all invites without OSP
  387. # peering tokens
  388. # sl_send_reply("401", "Unauthorized");
  389. # return;
  390. }
  391. log(2, "----ROUTE: Authentication passed\n");
  392. # Routing
  393. # if (lookup("location")) {
  394. # log(2, "----ROUTE: Registered user, forward the message\n");
  395. # append_hf("P-hint: usrloc\r\n");
  396. # t_relay();
  397. # } else {
  398. # log(2, "----ROUTE: Unregistered user, use OSP to get routing\n");
  399. # route(2);
  400. # }
  401. log(2, "----ROUTE: Use OSP to get routing\n");
  402. route(2);
  403. } else if (method=="ACK") {
  404. log(2, "----ROUTE: Processing ACK\n");
  405. if (t_check_trans()) {
  406. log(2, "----ROUTE: Relay E2E ACK\n");
  407. t_relay();
  408. } else {
  409. log(2, "----ROUTE: Not to relay ACK");
  410. }
  411. } else if (method=="BYE") {
  412. log(2, "----ROUTE: Processing BYE\n");
  413. xlog("L_INFO", "----ROUTE: R=$hdr(Route)\n");
  414. if (t_check_trans()) {
  415. log(2, "----ROUTE: Duplicated BYE\n");
  416. return;
  417. }
  418. # NOTE - don't t_relay before reporting usage
  419. if (is_direction("downstream")) {
  420. log(2, "----ROUTE: BYE from SOURCE\n");
  421. if (!reportospusage("0")) {
  422. xlog("L_WARN", "----ROUTE: failed to report usage, from '$fu' to '$tu'\n");
  423. }
  424. } else {
  425. log(2, "----ROUTE: BYE from DESTINATION\n");
  426. if (!reportospusage("1")) {
  427. xlog("L_WARN", "----ROUTE: failed to report usage, from '$fu' to '$tu'\n");
  428. }
  429. }
  430. t_relay();
  431. } else if (method=="CANCEL") {
  432. log(2, "----ROUTE: Processing CANCEL\n");
  433. if (t_check_trans()) {
  434. t_relay();
  435. } else {
  436. xlog("L_WARN", "----ROUTE: CANCEL without matching transaction, from '$fu' to '$tu'\n");
  437. }
  438. } else if ((method=="OPTIONS") && (uri==myself)) {
  439. log(2, "----ROUTE: Processing OPTIONS\n");
  440. options_reply();
  441. } else if (method=="PRACK") {
  442. log(2, "----ROUTE: Processing PRACK\n");
  443. t_relay();
  444. } else if (method=="INFO") {
  445. log(2, "----ROUTE: Processing INFO\n");
  446. t_relay();
  447. } else if (method=="UPDATE") {
  448. log(2, "----ROUTE: Processing UPDATE\n");
  449. t_relay();
  450. # } else if (method=="REGISTER") {
  451. # log(2, "----ROUTE: Processing REGISTER\n");
  452. #
  453. # # Stop retransmission
  454. # sl_send_reply("100", "Trying");
  455. #
  456. # if (uri==myself) {
  457. # log(2, "----ROUTE: Registered\n");
  458. # save("location");
  459. # } else {
  460. # log(2, "----ROUTE: Register from outside domain rejected\n");
  461. # sl_send_reply("488", "Unknown Domain");
  462. # }
  463. } else {
  464. xlog("L_WARN", "----ROUTE: Unsupported message, $rm from '$fu' to '$tu'\n");
  465. sl_send_reply("500", "Unsupported Message");
  466. }
  467. log(3, "----ROUTE: Route OUT\n");
  468. }
  469. # OSP Authorization and Routing
  470. route[2] {
  471. log(3, "OSP authorization and routing logic\n");
  472. # Is request to a phone number?
  473. # A phone number consists of digits (0 through 9)
  474. # and can begin with +
  475. # if (uri=~"sip:[+,0-9][0-9]*@") {
  476. # Requesting OSP peering routing and authorization
  477. # The request may fail if:
  478. # o OSP peering servers are not available
  479. # o Authentication failed
  480. # o There is no route to destination or the route is blocked
  481. log(3, "Requesting OSP authorization and routing\n");
  482. # Get source network ID
  483. # OpenSIPS can include a specific header parameter as the
  484. # source NetworkId in an OSP AuthorizationRequest to an OSP
  485. # server. Below are two example configurations for this
  486. # feature.
  487. #
  488. # Uncomment the line below to use the otg parameter value in
  489. # the From URI ($fu) as the source NetworkId ($avp(snid)).
  490. # if ($(fu{param.value, otg}) != NULL) {
  491. # $avp(snid) = $(fu{param.value, otg});
  492. # }
  493. #
  494. # Uncomment the line below to use P-Call-Owner SIP header
  495. # value as the source NetworkId ($avp(snid)).
  496. # if ($hdr(P-Call-Owner) != NULL) {
  497. # $avp(snid) = $hdr(P-Call-Owner);
  498. # }
  499. #
  500. # Uncomment the line below to use P-Network-ID SIP header
  501. # value as the source NetworkId ($avp(snid)).
  502. if ($hdr(P-Network-ID) != NULL) {
  503. $avp(snid) = $hdr(P-Network-ID);
  504. }
  505. # Get custom info
  506. if ($hdr(P-Custom-Info) != NULL) {
  507. $avp(cinfo) = $hdr(P-Custom-Info);
  508. }
  509. requestosprouting();
  510. switch ($retcode) {
  511. # To change the OpenSIPS response for specific use cases,
  512. # edit the 'sl_send-reply...' lines in the cases above.
  513. # For example, to change the SIP response for a blocked
  514. # route from 403 to 404 change the line
  515. # sl_send_reply("403", "Forbidden - Call is blocked");
  516. # to
  517. # sl_send_reply("404", "Forbidden - Call is blocked");
  518. case 1:
  519. log(3, "Response received\n");
  520. # Now we have 3 options.
  521. # o route(3) - sends a redirect to all available
  522. # routes
  523. # o route(4) - fork off to all available routes
  524. # o route(5) in conjunction with failure_route(1) -
  525. # sequentially tries all routes
  526. # route(3);
  527. # route(4);
  528. route(5);
  529. break;
  530. case -403:
  531. xlog("L_WARN", "----ROUTE: Call to '$tU' from source device '$si' is blocked on OSP Server.\n");
  532. sl_send_reply("403", "Forbidden - Call is blocked");
  533. break;
  534. case -404:
  535. xlog("L_WARN", "----ROUTE: No route on OSP server for call to '$tU' from source device '$si'.\n");
  536. sl_send_reply("404", "Route Not Found");
  537. break;
  538. case -2:
  539. log(2, "----ROUTE: Internal server error\n");
  540. sl_send_reply("500", "Internal Server Error");
  541. break;
  542. default:
  543. log(2, "----ROUTE: OSP Authorization failed\n");
  544. sl_send_reply("503", "Service Not Available");
  545. }
  546. # } else {
  547. # log(3, "Wrong phone number\n");
  548. # sl_send_reply("401", "Not Phone Number");
  549. # }
  550. }
  551. # The SIP 300 message indicates multiple destinations are returned
  552. # for the call. The user agent can try one or more the destinations
  553. # to complete the call.
  554. # The SIP 301 message indicates that the called party has moved
  555. # permanently and cannot be found at the Request-URI address. A 301
  556. # response would not be a expected response for an OSP query.
  557. # The SIP 302 message indicates the user agent SHOULD retry the request
  558. # at the new address(es) given in the redirect Contact header field.
  559. #
  560. # To change the SIP response for the route[3] use case, edit the
  561. # sl_send_reply... configuration. For example, to change the 300
  562. # response to 302, change from
  563. # sl_send_reply("300", "Redirect");
  564. # to
  565. # sl_send_reply("302", "Redirect");
  566. route[3] {
  567. log(3, "Prepare all routes and redirect\n");
  568. if (prepareallosproutes()) {
  569. sl_send_reply("300", "Redirect");
  570. } else {
  571. log(3, "Failed to prepare all routes\n");
  572. sl_send_reply("500", "Internal Server Error");
  573. }
  574. }
  575. route[4] {
  576. log(3, "Prepare all routes and fork-off\n");
  577. if (prepareallosproutes()) {
  578. t_relay();
  579. } else {
  580. log(3, "Failed to prepare all routes\n");
  581. sl_send_reply("500", "Internal Server Error");
  582. }
  583. }
  584. route[5] {
  585. log(3, "Try the 1st route\n");
  586. if (checkosproute()) {
  587. t_on_branch("1");
  588. t_on_failure("1");
  589. # For SIP From header modification
  590. # route(6);
  591. t_relay();
  592. } else {
  593. log(3, "Could not use the 1st route\n");
  594. sl_send_reply("500", "Internal Server Error");
  595. }
  596. }
  597. # For SIP From header modification
  598. #route[6] {
  599. # log(3, "Remove otg parameter\n");
  600. #
  601. # if ($(fu{param.value, otg})) {
  602. # $avp(from) = $fu;
  603. # avp_subst("$avp(from)", "/(.*);otg=([^;]*)(.*)/\1\3/");
  604. # xlog("L_INFO", "----ROUTE: New From URI = $avp(from)\n");
  605. # uac_replace_from("$avp(from)");
  606. # } else {
  607. # log(3, "Without otg parameter\n");
  608. # }
  609. #}
  610. failure_route[1] {
  611. if (t_check_status("487")) {
  612. log(3, "Call canceled (status 487)\n");
  613. return;
  614. }
  615. if (t_check_status("486")) {
  616. log(3, "User busy (status 486)\n");
  617. return;
  618. }
  619. if (t_check_status("408")) {
  620. if (!t_local_replied("last")) {
  621. log(3, "User unavailable (status 408)\n");
  622. return;
  623. }
  624. }
  625. log(3, "Try the next route\n");
  626. if (checkosproute()) {
  627. t_on_branch("1");
  628. t_on_failure("1");
  629. t_relay();
  630. } else {
  631. xlog("L_WARN", "----ROUTE: All destinations attempted for call ID '$ci'. Call cannot be completed.\n");
  632. t_reply("503", "Service Not Available - Call cannot be completed");
  633. }
  634. }
  635. branch_route[1] {
  636. log(3, "Prepare route specific OSP information\n");
  637. prepareosproute();
  638. # Only add/change Remote-Party-ID if calling number is translated
  639. if (checkcallingtranslation()) {
  640. log(3, "Calling number translated, add a new RPID header\n");
  641. # Remove the Remote_Party-ID from the received message
  642. # Otherwise it will be forwarded on to the next hop
  643. remove_hf("Remote-Party-ID");
  644. # Append a new Remote_Party
  645. append_rpid_hf();
  646. }
  647. }