README 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. OSP Module for Secure, Multi-Lateral Peering
  2. Ulrich Abend
  3. FhG FOKUS
  4. <[email protected]>
  5. Edited by
  6. Di-Shi Sun
  7. TransNexus, Inc.
  8. <[email protected]>
  9. Copyright © 2003 FhG FOKUS
  10. __________________________________________________________________
  11. Table of Contents
  12. 1. User's Guide
  13. 1. Overview
  14. 2. Dependencies
  15. 3. Exported Parameters
  16. 3.1. sp1_uri, sp2_uri, ..., sp16_uri
  17. 3.2. device_ip
  18. 3.3. token_format
  19. 3.4. private_key, local_certificate, ca_certificates
  20. 3.5. sp1_weight, sp2_weight, ..., sp16_weight
  21. 3.6. device_port
  22. 3.7. enable_crypto_hardware_support
  23. 3.8. ssl_lifetime
  24. 3.9. persistence
  25. 3.10. retry_delay
  26. 3.11. retry_limit
  27. 3.12. timeout
  28. 3.13. max_destinations
  29. 3.14. validate_call_id
  30. 3.15. use_rpid_for_calling_number
  31. 4. Exported Functions
  32. 4.1. checkospheader()
  33. 4.2. validateospheader()
  34. 4.3. requestosprouting()
  35. 4.4. prepareospfirstroute()
  36. 4.5. prepareosprnextoute()
  37. 4.6. appendospheaders()
  38. 4.7. prepareallosproute()
  39. 4.8. reportospusage()
  40. 2. Developer's Guide
  41. 3. Frequently Asked Questions
  42. List of Examples
  43. 1.1. Setting the OSP servers
  44. 1.2. Setting the device IP address
  45. 1.3. Setting the token format
  46. 1.4. Set authorization files
  47. 1.5. Setting the OSP server weights
  48. 1.6. Setting the device port
  49. 1.7. Setting the hardware support
  50. 1.8. Setting the ssl lifetime
  51. 1.9. Setting the persistence
  52. 1.10. Setting the retry delay
  53. 1.11. Setting the retry limit
  54. 1.12. Setting the timeout
  55. 1.13. Setting the number of destination
  56. 1.14. Instructing the module to validate call id
  57. 1.15. Instructing the module to use calling number in Remote-Party-ID
  58. 1.16. checkospheader usage
  59. 1.17. validateospheader usage
  60. 1.18. requestosprouting usage
  61. 1.19. prepareospfirstroute usage
  62. 1.20. prepareospnextroute usage
  63. 1.21. appendospheaders usage
  64. 1.22. prepareallosproute usage
  65. 1.23. reportospusage usage
  66. Chapter 1. User's Guide
  67. Table of Contents
  68. 1. Overview
  69. 2. Dependencies
  70. 3. Exported Parameters
  71. 3.1. sp1_uri, sp2_uri, ..., sp16_uri
  72. 3.2. device_ip
  73. 3.3. token_format
  74. 3.4. private_key, local_certificate, ca_certificates
  75. 3.5. sp1_weight, sp2_weight, ..., sp16_weight
  76. 3.6. device_port
  77. 3.7. enable_crypto_hardware_support
  78. 3.8. ssl_lifetime
  79. 3.9. persistence
  80. 3.10. retry_delay
  81. 3.11. retry_limit
  82. 3.12. timeout
  83. 3.13. max_destinations
  84. 3.14. validate_call_id
  85. 3.15. use_rpid_for_calling_number
  86. 4. Exported Functions
  87. 4.1. checkospheader()
  88. 4.2. validateospheader()
  89. 4.3. requestosprouting()
  90. 4.4. prepareospfirstroute()
  91. 4.5. prepareosprnextoute()
  92. 4.6. appendospheaders()
  93. 4.7. prepareallosproute()
  94. 4.8. reportospusage()
  95. 1. Overview
  96. The OSP module enables SER to support secure, multi-lateral peering
  97. using the OSP standard defined by ETSI (TS 101 321 V4.1.1). This module
  98. will enable your SER to:
  99. * Send a peering authorization request to a peering server.
  100. * Validate a digitally signed peering authorization token received in
  101. a SIP INVITE message.
  102. * Report usage information to a peering server.
  103. 2. Dependencies
  104. The OSP module depends on the following modules which must be loaded
  105. before the OSP module.
  106. * sl -- stateless replier
  107. * tm -- stateful processing
  108. * rr -- Record-Route/Route operation
  109. * textops -- text based operation
  110. * avpops -- AVP operation
  111. * OSP Toolkit -- The OSP Toolkit, available from
  112. http://sourceforge.net/projects/osp-toolkit, must be built before
  113. building SER with the OSP Module. For instructions on building SER
  114. with the OSP Toolkit, see
  115. http://www.transnexus.com/White%20Papers/Multi-Lateral_Peering_with
  116. _SER_V2.0.x.pdf
  117. 3. Exported Parameters
  118. 3.1. sp1_uri, sp2_uri, ..., sp16_uri
  119. 3.2. device_ip
  120. 3.3. token_format
  121. 3.4. private_key, local_certificate, ca_certificates
  122. 3.5. sp1_weight, sp2_weight, ..., sp16_weight
  123. 3.6. device_port
  124. 3.7. enable_crypto_hardware_support
  125. 3.8. ssl_lifetime
  126. 3.9. persistence
  127. 3.10. retry_delay
  128. 3.11. retry_limit
  129. 3.12. timeout
  130. 3.13. max_destinations
  131. 3.14. validate_call_id
  132. 3.15. use_rpid_for_calling_number
  133. 3.1. sp1_uri, sp2_uri, ..., sp16_uri
  134. These sp_uri (string) parameters define peering servers to be used for
  135. requesting peering authorization and routing information. At least one
  136. peering server must be configured. Others are required only if there
  137. are more than one peering servers. Each peering server address takes
  138. the form of a standard URL, and consists of up to four components:
  139. * An optional indication of the protocol to be used for communicating
  140. with the peering server. Both HTTP and HTTP secured with SSL/TLS
  141. are supported and are indicated by "http://" and "https://"
  142. respectively. If the protocol is not explicitly indicated, the SER
  143. defaults to HTTP secured with SSL.
  144. * The Internet domain name for the peering server. An IP address may
  145. also be used, provided it is enclosed in square brackets such as
  146. [172.16.1.1].
  147. * An optional TCP port number for communicating with the peering
  148. server. If the port number is omitted, the SER defaults to port
  149. 1080 (for HTTP) or port 1443 (for HTTP secured with SSL).
  150. The uniform resource identifier for requests to the peering server.
  151. This component is not optional and must be included.
  152. Example 1.1. Setting the OSP servers
  153. modparam("osp","sp1_uri","http://osptestserver.transnexus.com:1080/osp")
  154. modparam("osp","sp2_uri","https://[1.2.3.4]:1443/osp")
  155. 3.2. device_ip
  156. The device_ip (string) is a recommended parameter that explicitly
  157. defines the IP address of SER in a peering request message (as
  158. SourceAlternate type=transport). The IP address must be in brackets as
  159. shown in the example below.
  160. Example 1.2. Setting the device IP address
  161. modparam("osp","device_ip","[1.1.1.1]")
  162. 3.3. token_format
  163. When SER receives a SIP INVITE with a peering token, the OSP Module
  164. will validate the token to determine whether or not the call has been
  165. authorized by a peering server. Peering tokens may, or may not, be
  166. digitally signed. The token format (integer) parameter defines if SER
  167. will validate signed or unsigned tokens or both. The values for token
  168. format are defined below. The default value is 2.
  169. 0 - Validate only signed tokens. Calls with valid signed tokens are
  170. allowed.
  171. 1 - Validate only unsigned tokens. Calls with valid unsigned tokens are
  172. allowed.
  173. 2 - Validate both signed and unsigned tokens are allowed. Calls with
  174. valid tokens are allowed.
  175. Example 1.3. Setting the token format
  176. modparam("osp","token_format",2)
  177. 3.4. private_key, local_certificate, ca_certificates
  178. These parameters identify files are used for validating peering
  179. authorization tokens and establishing a secure channel between SER and
  180. a peering server using SSL. The files are generated using the 'Enroll'
  181. utility from the OSP Toolkit. By default, the proxy will look for
  182. pkey.pem, localcert.pem, and cacart_0.pem in the default configuration
  183. directory. The default config directory is set at compile time using
  184. CFG_DIR and defaults to /usr/local/etc/ser/. The files may be copied to
  185. the expected file location or the parameters below may be changed.
  186. Example 1.4. Set authorization files
  187. If the default CFG_DIR value was used at compile time, the files will
  188. be loaded from:
  189. modparam("osp","private_key","/usr/local/etc/ser/pkey.pem")
  190. modparam("osp","local_certificate","/usr/local/etc/ser/localcert.pem")
  191. modparam("osp","ca_certificates","/usr/local/etc/ser/cacert.pem")
  192. 3.5. sp1_weight, sp2_weight, ..., sp16_weight
  193. These sp_weight (integer) parameters are used for load balancing
  194. peering requests to peering servers. These parameters are most
  195. effective when configured as factors of 1000. For example, if sp1_uri
  196. should manage twice the traffic load of sp2_uri, then set sp1_weight to
  197. 2000 and sp2_weight to 1000. Shared load balancing between peering
  198. servers is recommended. However, peering servers can be configured as
  199. primary and backup by assigning a sp_weight of 0 to the primary server
  200. and a non-zero sp_weight to the back-up server. The default values for
  201. sp1_weight and sp2_weight are 1000.
  202. Example 1.5. Setting the OSP server weights
  203. modparam("osp","sp1_weight",1000)
  204. 3.6. device_port
  205. The device_port (string) parameter is an optional field which includes
  206. the SIP port being used by SER in the peering request (as
  207. SourceAlternate type=network) to the peering server. If is not
  208. configured, this information is not included in the peering request.
  209. This field is useful if multiple SERs are running on the same Linux
  210. computer since it enables the peering server to administer different
  211. peering policies based on different SIP proxies. This parameter has not
  212. been implemented yet.
  213. Example 1.6. Setting the device port
  214. modparam("osp","device_port","5060")
  215. 3.7. enable_crypto_hardware_support
  216. The enable_crypto_hardware_support (integer) parameter is used to set
  217. the cryptographic hardware acceleration engine in the openssl library.
  218. The default value is 0 (no crypto hardware is present). If crypto
  219. hardware is used, the value should be set to 1.
  220. Example 1.7. Setting the hardware support
  221. modparam("osp","enable_crypto_hardware_support",0)
  222. 3.8. ssl_lifetime
  223. The ssl_lifetime (integer) parameter defines the lifetime, in seconds,
  224. of a single SSL session key. Once this time limit is exceeded, the OSP
  225. Module will negotiate a new session key. Communication exchanges in
  226. progress will not be interrupted when this time limit expires. This is
  227. an optional field with default value is 200 seconds.
  228. Example 1.8. Setting the ssl lifetime
  229. modparam("osp","ssl_lifetime",200)
  230. 3.9. persistence
  231. The persistence (integer) parameter defines the time, in seconds, that
  232. an HTTP connection should be maintained after the completion of a
  233. communication exchange. The OSP Module will maintain the connection for
  234. this time period in anticipation of future communication exchanges to
  235. the same peering server.
  236. Example 1.9. Setting the persistence
  237. modparam("osp","persistence",1000)
  238. 3.10. retry_delay
  239. The retry_delay (integer) parameter defines the time, in seconds,
  240. between retrying connection attempts to an OSP peering server. After
  241. exhausting all peering servers the OSP Module will delay for this
  242. amount of time before resuming connection attempts. This is an optional
  243. field with default value is 1 second.
  244. Example 1.10. Setting the retry delay
  245. modparam("osp","retry_delay",1)
  246. 3.11. retry_limit
  247. The retry_limit (integer) parameter defines the maximum number of
  248. retries for connection attempts to a peering server. If no connection
  249. is established after this many retry attempts to all peering servers,
  250. the OSP Module will cease connection attempts and return appropriate
  251. error codes. This number does not count the initial connection attempt,
  252. so that a retry_limit of 1 will result in a total of two connection
  253. attempts to every peering server. The default value is 2.
  254. Example 1.11. Setting the retry limit
  255. modparam("osp","retry_limit",2)
  256. 3.12. timeout
  257. The timeout (integer) parameter defines the maximum time in
  258. milliseconds, to wait for a response from a peering server. If no
  259. response is received within this time, the current connection is
  260. aborted and the OSP Module attempts to contact the next peering server.
  261. The default value is 10 seconds.
  262. Example 1.12. Setting the timeout
  263. modparam("osp","timeout",10)
  264. 3.13. max_destinations
  265. The max_destinations (integer) parameter defines the maximum number of
  266. destinations that SER requests the peering server to return in a
  267. peering response. The default value is 5.
  268. Example 1.13. Setting the number of destination
  269. modparam("osp","max_destinations",5)
  270. 3.14. validate_call_id
  271. The validate_call_id (integer) parameter instructs the OSP module to
  272. validate call id in the peering token. If this value is set to 1, the
  273. OSP Module validates that the call id in the SIP INVITE message matches
  274. the call id in the peering token. If they do not match the INVITE is
  275. rejected. If this value is set to 0, the OSP Module will not validate
  276. the call id in the peering token. The default value is 1.
  277. Example 1.14. Instructing the module to validate call id
  278. modparam("osp","validate_call_id",1)
  279. 3.15. use_rpid_for_calling_number
  280. The use_rpid_for_calling_number(integer) parameter instructs the OSP
  281. module to use the calling number in the Remote-Party-ID of the SIP
  282. INVITE message. If this value is set to 1, the OSP Module uses the
  283. calling number in the Reomte-Party-ID header of the INVITE message when
  284. a Remote-Party-ID exists. If this value is set to 0, the OSP Module
  285. will use the calling number in the From header of the INVITE message.
  286. The default value is 1.
  287. Example 1.15. Instructing the module to use calling number in
  288. Remote-Party-ID
  289. modparam("osp","use_rpid_calling_number",1)
  290. 4. Exported Functions
  291. 4.1. checkospheader()
  292. 4.2. validateospheader()
  293. 4.3. requestosprouting()
  294. 4.4. prepareospfirstroute()
  295. 4.5. prepareosprnextoute()
  296. 4.6. appendospheaders()
  297. 4.7. prepareallosproute()
  298. 4.8. reportospusage()
  299. 4.1. checkospheader()
  300. This function checks for the existence of the OSP-Auth-Token header
  301. field.
  302. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  303. Example 1.16. checkospheader usage
  304. ...
  305. if (checkospheader()) {
  306. log("OSP header field found.\n");
  307. } else {
  308. log("no OSP header field present\n");
  309. };
  310. ...
  311. 4.2. validateospheader()
  312. This function validates an OSP-Token specified in the
  313. OSP-Auth-Tokenheader field of the SIP message. If a peering token is
  314. present, it will be validated locally. If no OSP header is found or the
  315. header token is invalid or expired, -1 is returned; on successful
  316. validation 1 is returned.
  317. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  318. Example 1.17. validateospheader usage
  319. ...
  320. if (validateospheader()) {
  321. log("valid OSP header found\n");
  322. } else {
  323. log("OSP header not found, invalid or expired\n");
  324. };
  325. ...
  326. 4.3. requestosprouting()
  327. This function launches a query to the peering server requesting the IP
  328. address of one or more destination peers serving the called party. If
  329. destination peers are available, the peering server will return the IP
  330. address and a peering authorization token for each destination peer.
  331. The OSP-Auth-Token Header field is inserted into the SIP message and
  332. the SIP uri is rewritten to the IP address of destination peer provided
  333. by the peering server.
  334. The address of the called party must be a valid E164 number, otherwise
  335. this function returns -1. If the transaction was accepted by the
  336. peering server, the uri is being rewritten and 1 returned, on errors
  337. (peering servers are not available, authentication failed or there is
  338. no route to destination or the route is blocked) -1 is returned.
  339. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  340. Example 1.18. requestosprouting usage
  341. ...
  342. if (requestosprouting()) {
  343. log("successfully queried OSP server, now relaying call\n");
  344. } else {
  345. log("Authorization request was rejected from OSP server\n");
  346. };
  347. ...
  348. 4.4. prepareospfirstroute()
  349. This function tries to prepare the INVITE to be forwarded or redirected
  350. using the first destination in the list returned by the peering server.
  351. If the route could not be prepared, the function returns 'FALSE' back
  352. to the script, which can then decide how to handle the failure.
  353. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  354. Example 1.19. prepareospfirstroute usage
  355. ...
  356. if (prepareospfirstroute ()) {
  357. log("successfully prepared the first route, now relaying call\n");
  358. } else {
  359. log("could not prepare the route. The first destination was blocked\n");
  360. };
  361. ...
  362. 4.5. prepareosprnextoute()
  363. Once the call could not be completed through the first destination,
  364. this function tries to prepare the INVITE message using the next
  365. destination in the list returned by the peering Server. If it succeeds
  366. in preparing the route, the message is either redirected or relayed on
  367. (using the t_relay call), or else the function returns 'FALSE' back to
  368. the script, which can then decide how to handle the failure.
  369. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  370. Example 1.20. prepareospnextroute usage
  371. ...
  372. if (prepareospnextroute ()) {
  373. log("successfully prepared the next route, now relaying call\n");
  374. } else {
  375. log("could not prepare the route. No next destination available\n");
  376. };
  377. ...
  378. 4.6. appendospheaders()
  379. This function is used to append route specific OSP headers. Before
  380. calling appendospheaders, prepareospfirst/nextroute should be called.
  381. This function can be used from BRANCH_ROUTE.
  382. Example 1.21. appendospheaders usage
  383. ...
  384. branch_route[1] {
  385. log("Prepare route specific OSP information\n");
  386. appendospheaders();
  387. }
  388. ...
  389. 4.7. prepareallosproute()
  390. This function tries to prepare all the routes in the list returned by
  391. the peering server. The message is then either forked off or redirected
  392. to the destination. If unsuccessful in preparing the routes a SIP 500
  393. is sent back and a trace message is logged.
  394. This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.
  395. Example 1.22. prepareallosproute usage
  396. ...
  397. if (prepareallosproute()) {
  398. log("Routes are prepared, now either forking or redirecting the call\n");
  399. } else {
  400. log("Could not prepare the routes. No destination available\n");
  401. };
  402. ...
  403. 4.8. reportospusage()
  404. This function should be called after receiving a BYE message. If the
  405. message contains an OSP cookie, the function will forward originating
  406. and/or terminating duration usage information to a peering server. The
  407. function returns TRUE if the BYE includes an OSP cookie. The actual
  408. usage message will be send on a different thread and will not delay BYE
  409. processing. The function should be called before relaying the message.
  410. This function can be used from REQUEST_ROUTE.
  411. Example 1.23. reportospusage usage
  412. ...
  413. if (reportospusage ()) {
  414. log("OSP call duration usage will be reported\n");
  415. } else {
  416. log("The BYE message does not include OSP information, it was not authorized b
  417. y an OSP server\n");
  418. };
  419. ...
  420. Chapter 2. Developer's Guide
  421. The functions of the OSP modules are not used by other SER modules.
  422. Chapter 3. Frequently Asked Questions
  423. 3.1. What platforms does this module work on?
  424. 3.2. Where can I get more information on this module?
  425. 3.3. Where can I get more information on OSP?
  426. 3.4. How do I obtain an OSP server for testing?
  427. 3.5. How are the exported functions used by the OSP module?
  428. 3.1.
  429. What platforms does this module work on?
  430. The module has been implemented using Linux, the underlying toolkit and
  431. the module code itself should compile and work on Solaris, *BSD, and
  432. probably most other unix platforms with ssl and pthreads available, but
  433. the OSP Module has only been tested Linux.
  434. 3.2.
  435. Where can I get more information on this module?
  436. Please see http://www.iptel.org/views/moduledocs/ or post a message on
  437. the SER mailing list.
  438. 3.3.
  439. Where can I get more information on OSP?
  440. The OSP technical specification (ETSI TS 101 321) may be obtained from
  441. www.etsi.org. You can also post a message on the OSP Toolkit mailing
  442. list at
  443. https://lists.sourceforge.net/lists/listinfo/osp-toolkit-client.
  444. 3.4.
  445. How do I obtain an OSP server for testing?
  446. OSP peering servers are available from the following sources:
  447. * OpenOSP is an OSP server reference implementation created by Cisco
  448. Systems and available at
  449. http://www.vovida.org/applications/downloads/openosp/
  450. * RAMS is an open source, java based OSP server project available
  451. from http://sourceforge.net/projects/rams/
  452. * A free version of the commercial TransNexus OSP peering server is
  453. available at www.transnexus.com.
  454. 3.5.
  455. How are the exported functions used by the OSP module?
  456. See sample-osp-ser.cfg in modules/osp/etc for examples