瀏覽代碼

according to Di-Shi are K's and ser's osp module more or less the same, whereas Kamailio's osp module should be more up2date than ser's module. Thus, ser's osp module will be removed and K's osp module will be used as common OSP module.

Klaus Darilion 16 年之前
父節點
當前提交
6bdbd8e2ab
共有 61 個文件被更改,包括 0 次插入5629 次删除
  1. 0 0
      modules/osp/Makefile
  2. 0 0
      modules/osp/README
  3. 0 0
      modules/osp/RELEASE-NOTES.txt
  4. 0 0
      modules/osp/destination.c
  5. 0 0
      modules/osp/destination.h
  6. 0 0
      modules/osp/doc/Makefile
  7. 0 0
      modules/osp/doc/osp.xml
  8. 0 0
      modules/osp/doc/osp_admin.xml
  9. 0 0
      modules/osp/doc/osp_devel.xml
  10. 0 0
      modules/osp/etc/cacert_0.pem
  11. 0 0
      modules/osp/etc/localcert.pem
  12. 0 0
      modules/osp/etc/pkey.pem
  13. 0 0
      modules/osp/etc/sample-osp-openser.cfg
  14. 0 0
      modules/osp/globals.c
  15. 0 0
      modules/osp/orig_transaction.c
  16. 0 0
      modules/osp/orig_transaction.h
  17. 0 0
      modules/osp/osp_mod.c
  18. 0 0
      modules/osp/osp_mod.h
  19. 0 0
      modules/osp/osptoolkit.c
  20. 0 0
      modules/osp/osptoolkit.h
  21. 0 0
      modules/osp/provider.c
  22. 0 0
      modules/osp/provider.h
  23. 0 0
      modules/osp/sipheader.c
  24. 0 0
      modules/osp/sipheader.h
  25. 0 0
      modules/osp/term_transaction.c
  26. 0 0
      modules/osp/term_transaction.h
  27. 0 0
      modules/osp/tm.c
  28. 0 0
      modules/osp/tm.h
  29. 0 0
      modules/osp/usage.c
  30. 0 0
      modules/osp/usage.h
  31. 0 51
      modules_s/osp/Makefile
  32. 0 564
      modules_s/osp/README
  33. 0 62
      modules_s/osp/RELEASE-NOTES.txt
  34. 0 473
      modules_s/osp/destination.c
  35. 0 84
      modules_s/osp/destination.h
  36. 0 4
      modules_s/osp/doc/Makefile
  37. 0 54
      modules_s/osp/doc/osp.xml
  38. 0 20
      modules_s/osp/doc/osp_devel.xml
  39. 0 50
      modules_s/osp/doc/osp_faq.xml
  40. 0 369
      modules_s/osp/doc/osp_user.xml
  41. 0 10
      modules_s/osp/etc/cacert_0.pem
  42. 0 10
      modules_s/osp/etc/localcert.pem
  43. 0 9
      modules_s/osp/etc/pkey.pem
  44. 0 463
      modules_s/osp/etc/sample-osp-ser.cfg
  45. 0 69
      modules_s/osp/globals.c
  46. 0 545
      modules_s/osp/orig_transaction.c
  47. 0 49
      modules_s/osp/orig_transaction.h
  48. 0 307
      modules_s/osp/osp_mod.c
  49. 0 64
      modules_s/osp/osp_mod.h
  50. 0 193
      modules_s/osp/osptoolkit.c
  51. 0 65
      modules_s/osp/osptoolkit.h
  52. 0 142
      modules_s/osp/provider.c
  53. 0 43
      modules_s/osp/provider.h
  54. 0 725
      modules_s/osp/sipheader.c
  55. 0 60
      modules_s/osp/sipheader.h
  56. 0 203
      modules_s/osp/term_transaction.c
  57. 0 45
      modules_s/osp/term_transaction.h
  58. 0 158
      modules_s/osp/tm.c
  59. 0 47
      modules_s/osp/tm.h
  60. 0 627
      modules_s/osp/usage.c
  61. 0 64
      modules_s/osp/usage.h

+ 0 - 0
modules_k/osp/Makefile → modules/osp/Makefile


+ 0 - 0
modules_k/osp/README → modules/osp/README


+ 0 - 0
modules_k/osp/RELEASE-NOTES.txt → modules/osp/RELEASE-NOTES.txt


+ 0 - 0
modules_k/osp/destination.c → modules/osp/destination.c


+ 0 - 0
modules_k/osp/destination.h → modules/osp/destination.h


+ 0 - 0
modules_k/osp/doc/Makefile → modules/osp/doc/Makefile


+ 0 - 0
modules_k/osp/doc/osp.xml → modules/osp/doc/osp.xml


+ 0 - 0
modules_k/osp/doc/osp_admin.xml → modules/osp/doc/osp_admin.xml


+ 0 - 0
modules_k/osp/doc/osp_devel.xml → modules/osp/doc/osp_devel.xml


+ 0 - 0
modules_k/osp/etc/cacert_0.pem → modules/osp/etc/cacert_0.pem


+ 0 - 0
modules_k/osp/etc/localcert.pem → modules/osp/etc/localcert.pem


+ 0 - 0
modules_k/osp/etc/pkey.pem → modules/osp/etc/pkey.pem


+ 0 - 0
modules_k/osp/etc/sample-osp-openser.cfg → modules/osp/etc/sample-osp-openser.cfg


+ 0 - 0
modules_k/osp/globals.c → modules/osp/globals.c


+ 0 - 0
modules_k/osp/orig_transaction.c → modules/osp/orig_transaction.c


+ 0 - 0
modules_k/osp/orig_transaction.h → modules/osp/orig_transaction.h


+ 0 - 0
modules_k/osp/osp_mod.c → modules/osp/osp_mod.c


+ 0 - 0
modules_k/osp/osp_mod.h → modules/osp/osp_mod.h


+ 0 - 0
modules_k/osp/osptoolkit.c → modules/osp/osptoolkit.c


+ 0 - 0
modules_k/osp/osptoolkit.h → modules/osp/osptoolkit.h


+ 0 - 0
modules_k/osp/provider.c → modules/osp/provider.c


+ 0 - 0
modules_k/osp/provider.h → modules/osp/provider.h


+ 0 - 0
modules_k/osp/sipheader.c → modules/osp/sipheader.c


+ 0 - 0
modules_k/osp/sipheader.h → modules/osp/sipheader.h


+ 0 - 0
modules_k/osp/term_transaction.c → modules/osp/term_transaction.c


+ 0 - 0
modules_k/osp/term_transaction.h → modules/osp/term_transaction.h


+ 0 - 0
modules_k/osp/tm.c → modules/osp/tm.c


+ 0 - 0
modules_k/osp/tm.h → modules/osp/tm.h


+ 0 - 0
modules_k/osp/usage.c → modules/osp/usage.c


+ 0 - 0
modules_k/osp/usage.h → modules/osp/usage.h


+ 0 - 51
modules_s/osp/Makefile

@@ -1,51 +0,0 @@
-# 
-#  ser osp module. 
-# 
-#  This module enables ser to communicate with an Open Settlement 
-#  Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
-#  defined standard for Inter-Domain VoIP pricing, authorization
-#  and usage exchange.  The technical specifications for OSP 
-#  (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
-# 
-#  Uli Abend was the original contributor to this module.
-#  
-#  Copyright (C) 2001-2005 Fhg Fokus
-# 
-#  This file is part of ser, a free SIP server.
-# 
-#  ser is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 2 of the License, or
-#  (at your option) any later version
-# 
-#  For a license to use the ser software under conditions
-#  other than those described here, or to purchase support for this
-#  software, please contact iptel.org by e-mail at the following addresses:
-#     [email protected]
-# 
-#  ser is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-# 
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-# 
-
-# WARNING: do not run this directly, it should be run by the master Makefile
-
-include ../../Makefile.defs
-auto_gen=
-NAME=osp.so
-DEFS+=-D_POSIX_THREADS
-
-LIBS=$(shell if [ -f /usr/local/lib/libosptk.a ]; then echo "-losptk" ; else echo "-losp" ; fi)
-LIBS+=-lssl -lcrypto -lpthread -lm
-
-
-
-DEFS+=-DSER_MOD_INTERFACE
-
-include ../../Makefile.modules
-

+ 0 - 564
modules_s/osp/README

@@ -1,564 +0,0 @@
-                  OSP Module for Secure, Multi-Lateral Peering
-
-  Ulrich Abend
-
-   FhG Fokus
-
-    Edited by
-
-  Di-Shi Sun
-
-   Copyright (c) 2003 FhG Fokus
-
-   ---------------------------------------------------------------------------
-
-   Table of Contents
-
-   [1]User's Guide
-
-                [2]Overview
-
-                [3]Dependencies
-
-                [4]Exported Parameters
-
-                             [5]sp1_uri, sp2_uri
-
-                             [6]device_ip
-
-                             [7]token_format
-
-                             [8]private_key, local_certificate,
-                             ca_certificates
-
-                             [9]sp1_weight, sp2_weight
-
-                             [10]device_port
-
-                             [11]enable_crypto_hardware_support
-
-                             [12]ssl_lifetime
-
-                             [13]persistence
-
-                             [14]retry_delay
-
-                             [15]retry_limit
-
-                             [16]timeout
-
-                             [17]max_destinations
-
-                             [18]validate_call_id
-
-                [19]Exported Functions
-
-                             [20]checkospheader()
-
-                             [21]validateospheader()
-
-                             [22]requestosprouting()
-
-                             [23]preparefirstosproute()
-
-                             [24]preparenextosproute()
-
-                             [25]prepareallosproute()
-
-                             [26]reportospusage()
-
-   [27]Developer's Guide
-
-   [28]Frequently Asked Questions
-
-   ---------------------------------------------------------------------------
-
-                                  User's Guide
-
-Overview
-
-   The OSP module enables SER to support secure, multi-lateral peering using
-   the OSP standard defined by ETSI (TS 101 321 V4.1.1). This module will
-   enable your SER to:
-
-     * Send a peering authorization request to a peering server.
-
-     * Validate a digitally signed peering authorization token received in a
-       SIP INVITE message.
-
-     * Report usage information to a peering server.
-
-   ---------------------------------------------------------------------------
-
-Dependencies
-
-   The OSP module depends on the following modules which must be loaded
-   before the OSP module.
-
-     * textops -- text based operation
-
-     * OSP Toolkit -- The OSP Toolkit, available from www.sipfoundry.org/OSP,
-       must be built before building SER with the OSP Module. See the
-       document "Multi-lateral Peering with SER", located at
-       http://developer.berlios.de/docman/?group_id=3799 for build
-       instructions.
-
-   ---------------------------------------------------------------------------
-
-Exported Parameters
-
-  sp1_uri, sp2_uri
-
-   These string parameters define peering servers to be used for requesting
-   peering authorization and routing information. sp1_uri must be configured.
-   sp2_uri is required only if there are two peering servers. Each peering
-   server address takes the form of a standard URL, and consists of up to
-   four components:
-
-     * An optional indication of the protocol to be used for communicating
-       with the peering server. Both HTTP and HTTP secured with SSL/TLS are
-       supported and are indicated by "http://" and "https://" respectively.
-       If the protocol is not explicitly indicated, the SER defaults to HTTP
-       secured with SSL.
-
-     * The Internet domain name for the peering server. An IP address may
-       also be used, provided it is enclosed in square brackets such as
-       [172.16.1.1].
-
-     * An optional TCP port number for communicating with the peering server.
-       If the port number is omitted, the SER defaults to port 1080 (for
-       HTTP) or port 1443 (for HTTP secured with SSL).
-
-       The uniform resource identifier for requests to the peering server.
-       This component is not optional and must be included.
-
-   Example 1. Setting the OSP servers
-
-   modparam ("osp", "sp1_uri", "http://osptestserver.transnexus.com:1080/osp") 
-   modparam ("osp", "sp2_uri", "https://[1.2.3.4]:1443/osp")                   
-                                                                               
-
-   ---------------------------------------------------------------------------
-
-  device_ip
-
-   device_ip (string) is a recommended parameter that explicitly defines the
-   IP address of SER in an peering request message (as SourceAlternate
-   type=transport). The IP address must be in brackets as shown in the
-   example below.
-
-   Example 2. Setting the device IP address
-
-   modparam ("osp", "device_ip", "[1.1.1.1]")                                 
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  token_format
-
-   When SER receives a SIP INVITE with a peering token, the OSP Module will
-   validate the token to determine whether or not the call has been
-   authorized by a peering server. Peering tokens may, or may not, be
-   digitally signed. The token format (integer) parameter defines if SER will
-   validate signed or unsigned tokens or both. The values for token format
-   are defined below. The default value is 2.
-
-   0 - Validate only signed tokens. Calls with valid signed tokens are
-   allowed.
-
-   1 - Validate only unsigned tokens. Calls with valid unsigned tokens are
-   allowed.
-
-   2 - Validate both signed and unsigned tokens are allowed. Calls with valid
-   tokens are allowed.
-
-   Example 3. Setting the token format
-
-   modparam ("osp", "token_format", 2)                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  private_key, local_certificate, ca_certificates
-
-   These parameters identify files are used for validating peering
-   authorization tokens and establishing a secure channel between SER and a
-   peering server using SSL. The files are generated using the 'Enroll'
-   utility from the OSP Toolkit. By default, the proxy will look for
-   pkey.pem, localcert.pem, and cacart_0.pem in the default configuration
-   directory. The default config directory is set at compile time using
-   CFG_DIR and defaults to /usr/local/etc/ser/. The files may be copied to
-   the expected file location or the parameters below may be changed.
-
-   Example 4. Set authorization files
-
-   If the default CFG_DIR value was used at compile time, the files will be
-   loaded from:
-
-   modparam ("osp", "private_key", "/usr/local/etc/ser/pkey.pem")             
-   modparam ("osp", "local_certificate", "/usr/local/etc/ser/localcert.pem")  
-   modparam ("osp", "ca_certificates", "/usr/local/etc/ser/cacert.pem")       
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  sp1_weight, sp2_weight
-
-   These sp_weight (integer) parameters are used for load balancing peering
-   requests to peering servers. These parameters are most effective when
-   configured as factors of 1000. For example, if sp1_uri should manage twice
-   the traffic load of sp2_uri, then set sp1_weight to 2000 and sp2_weight to
-   1000. Shared load balancing between peering servers is recommended.
-   However, peering servers can be configured as primary and backup by
-   assigning a sp_weight of 0 to the primary server and a non-zero sp_weight
-   to the back-up server. The default values for sp1_weight and sp2_weight
-   are 1000.
-
-   Example 5. Setting the OSP server weights
-
-   modparam ("osp", "sp1_weight", 1000)                                       
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  device_port
-
-   The device_port (string) parameter is an optional field which includes the
-   SIP port being used by SER in the peering request (as SourceAlternate
-   type=network) to the peering server. If is not configured, this
-   information is not included in the peering request. This field is useful
-   if multiple SERs are running on the same Linux computer since it enables
-   the peering server to administer different peering policies based on
-   different SIP proxies.
-
-   Example 6. Setting the device port
-
-   modparam ("osp", "device_port", "5060")                                    
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  enable_crypto_hardware_support
-
-   The enable_crypto_hardware_support (integer) parameter is used to set the
-   cryptographic hardware acceleration engine in the openssl library. The
-   default value is 0 (no crypto hardware is present). If crypto hardware is
-   used, the value should be set to 1.
-
-   Example 7. Setting the hardware support
-
-   modparam ("osp", "enable_crypto_hardware_support", 0)                      
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  ssl_lifetime
-
-   The ssl_lifetime (integer) parameter defines the lifetime, in seconds, of
-   a single SSL session key. Once this time limit is exceeded, the OSP Module
-   will negotiate a new session key. Communication exchanges in progress will
-   not be interrupted when this time limit expires. This is an optional field
-   with default value is 200 seconds.
-
-   Example 8. Setting the ssl lifetime
-
-   modparam ("osp", "ssl_lifetime", 200)                                      
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  persistence
-
-   The persistence (integer) parameter defines the time, in seconds, that an
-   HTTP connection should be maintained after the completion of a
-   communication exchange. The OSP Module will maintain the connection for
-   this time period in anticipation of future communication exchanges to the
-   same peering server.
-
-   Example 9. Setting the persistence
-
-   modparam ("osp", "persistence", 1000)                                      
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  retry_delay
-
-   The retry_delay (integer) parameter defines the time, in seconds, between
-   retrying connection attempts to an OSP peering server. After exhausting
-   all peering servers the OSP Module will delay for this amount of time
-   before resuming connection attempts. This is an optional field with
-   default value is 1 second.
-
-   Example 10. Setting the retry delay
-
-   modparam ("osp", "retry_delay", 1)                                         
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  retry_limit
-
-   The retry_limit (integer) parameter defines the maximum number of retries
-   for connection attempts to an peering server. If no connection is
-   established after this many retry attempts to all peering servers, the OSP
-   Module will cease connection attempts and return appropriate error codes.
-   This number does not count the initial connection attempt, so that a
-   retry_limit of 1 will result in a total of two connection attempts to
-   every peering server. The default value is 2.
-
-   Example 11. Setting the retry limit
-
-   modparam ("osp", "retry_limit", 2)                                         
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  timeout
-
-   The timeout (integer) parameter defines the maximum time in milliseconds,
-   to wait for a response from an peering server. If no response is received
-   within this time, the current connection is aborted and the OSP Module
-   attempts to contact the next peering server. The default value is 10
-   seconds.
-
-   Example 12. Setting the timeout
-
-   modparam ("osp", "timeout", 10)                                            
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  max_destinations
-
-   The max_destinations (integer) parameter defines the maximum number of
-   destinations that SER requests the peering server to return in a peering
-   response. The default value is 5.
-
-   Example 13. Setting the number of destination
-
-   modparam ("osp", "max_destinations", 5)                                    
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  validate_call_id
-
-   The validate_call_id (integer) parameter instructs the OSP module to
-   validate call id in the peering token. If this value is set to 1, the OSP
-   Module validates that the call id in the SIP INVITE message matches the
-   call id in the peering token. If they do not match the INVITE is rejected.
-   If this value is set to 0, the OSP Module will not validate the call id in
-   the peering token. The default value is 1
-
-   Example 14. Instructing the module to validate call id
-
-   modparam ("osp", "validate_call_id", 1)                                    
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-Exported Functions
-
-  checkospheader()
-
-   This function checks for the existence of the OSP-Auth-Token header field.
-
-   Example 15. checkospheader usage
-
-   ...                                                                        
-   if (checkospheader()) {                                                    
-     log("OSP header field found.\n");                                        
-   } else {                                                                   
-     log("no OSP header field present\n");                                    
-   };                                                                         
-   ...                                                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  validateospheader()
-
-   This function validates an OSP-Token specified in the OSP-Auth-Tokenheader
-   field of the SIP message. If a peering token is present, it will be
-   validated locally. If no OSP header is found or the header token is
-   invalid or expired, -1 is returned; on successful validation 1 is
-   returned.
-
-   Example 16. validateospheader usage
-
-   ...                                                                        
-   if (validateospheader()) {                                                 
-     log("valid OSP header found\n");                                         
-   } else {                                                                   
-     log("OSP header not found, invalid or expired\n");                       
-   };                                                                         
-   ...                                                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  requestosprouting()
-
-   This function launches a query to the peering server requesting the IP
-   address of one or more destination peers serving the called party. If
-   destination peers are available, the peering server will return the IP
-   address and a peering authorization token for each destination peer. The
-   OSP-Auth-Token Header field is inserted into the SIP message and the SIP
-   uri is rewritten to the IP address of destination peer provided by the
-   peering server.
-
-   The address of the called party must be a valid E164 number, otherwise
-   this function returns -1. If the transaction was accepted by the peering
-   server, the uri is being rewritten and 1 returned, on errors (peering
-   servers are not available, authentication failed or there is no route to
-   destination or the route is blocked) -1 is returned.
-
-   Example 17. requestosprouting usage
-
-   ...                                                                        
-   if (requestosprouting()) {                                                 
-     log("successfully queried OSP server, now relaying call\n");             
-   } else {                                                                   
-     log("Authorization request was rejected from OSP server\n");             
-   };                                                                         
-   ...                                                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  preparefirstosproute()
-
-   This function tries to prepare the INVITE to be forwarded or redirected
-   using the first destination in the list returned by the peering server. If
-   the route could not be prepared, the function returns 'FALSE' back to the
-   script, which can then decide how to handle the failure.
-
-   Example 18. preparefirstosproute usage
-
-   ...                                                                        
-   if (preparefirstosproute ()) {                                             
-     log("successfully prepared the first route, now relaying call\n");       
-   } else {                                                                   
-     log("could not prepare the route. The first destination was blocked\n"); 
-   };                                                                         
-   ...                                                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  preparenextosproute()
-
-   Once the call could not be completed through the first destination, this
-   function tries to prepare the INVITE message using the next destination in
-   the list returned by the peering Server. If it succeeds in preparing the
-   route, the message is either redirected or relayed on (using the t_relay
-   call), or else the function returns 'FALSE' back to the script, which can
-   then decide how to handle the failure.
-
-   Example 19. preparenextosproute usage
-
-   ...                                                                        
-   if (preparenextosproute ()) {                                              
-     log("successfully prepared the next route, now relaying call\n");        
-   } else {                                                                   
-     log("could not prepare the route. No next destination available\n");     
-   };                                                                         
-   ...                                                                        
-                                                                              
-
-   ---------------------------------------------------------------------------
-
-  prepareallosproute()
-
-   This function tries to prepare all the routes in the list returned by the
-   peering server. The message is then either forked off or redirected to the
-   destination. If unsuccessful in preparing the routes a SIP 500 is sent
-   back and a trace message is logged.
-
-   Example 20. prepareallosproute usage
-
-...                                                                                      
-if (prepareallosproute ()) {                                                             
-  log("successfully prepared the routes, now either forking or redirecting the call\n"); 
-} else {                                                                                 
-  log("could not prepare the route. No destination available\n");                        
-};                                                                                       
-...                                                                                      
-                                                                                         
-
-   ---------------------------------------------------------------------------
-
-  reportospusage()
-
-   This function should be called after receiving a BYE message. If the
-   message contains an OSP cookie, the function will forward originating
-   and/or terminating duration usage information to a peering server. The
-   function returns TRUE if the BYE includes an OSP cookie. The actual usage
-   message will be send on a different thread and will not delay BYE
-   processing. The function should be called before relaying the message.
-
-   Example 21. reportospusage usage
-
-...                                                                                                  
-if (reportospusage ()) {                                                                             
-  log("OSP call duration usage will be reported\n");                                                 
-} else {                                                                                             
-  log("The BYE message does not include OSP information, it was not authorized by an OSP server\n"); 
-};                                                                                                   
-...                                                                                                  
-                                                                                                     
-
-   ---------------------------------------------------------------------------
-
-                               Developer's Guide
-
-   The functions of the OSP modules are not used by other SER modules.
-
-   ---------------------------------------------------------------------------
-
-                           Frequently Asked Questions
-
-   Q: [29]What platforms does this module work on?
-
-   Q: [30]Where can I get more information on this module?
-
-   Q: [31]Where can I get more information on OSP?
-
-   Q: [32]How do I obtain an OSP server for testing?
-
-   Q: [33]How are the exported functions used by the OSP module?
-
-   Q: What platforms does this module work on?
-
-   A: The module has been implemented using Linux, the underlying toolkit and
-   the module code itself should compile and work on Solaris, *BSD, and
-   probably most other unix platforms with ssl and pthreads available, but
-   the OSP Module has only been tested Linux.
-
-   Q: Where can I get more information on this module?
-
-   A: Please see the document "Multi-Lateral Peering with SER" located at
-   http://developer.berlios.de/docman/?group_id=3799 or post a message on the
-   SER mailing list. You may also send an e-mail to [email protected].
-
-   Q: Where can I get more information on OSP?
-
-   A: The OSP technical specification (ETSI TS 101 321) may be obtained from
-   www.etsi.org. Additional documentation on OSP is available from
-   www.sipfoundry.org.
-
-   Q: How do I obtain an OSP server for testing?
-
-   A: OSP peering servers are available from the following sources:
-
-     * OpenOSP server from www.sipfoundry.org is a complete OSP server
-
-     * RAMS from www.sipfoundry.org is a new java based open source OSP
-
-     * TransNexus provides free access to a hosted OSP peering server on the
-       Internet for testing. Contact [email protected].
-
-   Q: How are the exported functions used by the OSP module?
-
-   A: See sample-osp-ser.cfg in modules/osp/etc for examples

+ 0 - 62
modules_s/osp/RELEASE-NOTES.txt

@@ -1,62 +0,0 @@
-
-June 23, 2005
-  Implemented routing and authorization validation.  The module can:
-   o Request authorization and routing information from an OSP server
-   o Use provided routes to:
-     o Redirect the originating UI to all routes OR
-     o Try all routes simultaneously using parallel forking OR
-     o Try routes in the order they were received using sequential forking
-   o Add and retrieve P-OSP-Auth-Token header
-   o Perform local validation of the P-OSP-Auth-Token
-
-September 12, 2005
-   o Bug 4863 - the module will remove OSP Auth token from the incoming Invite
-     after validating the token and before forwarding Invite to the next hop.
-   o Bug 4891 - added a new flag 'validate_call_id' for disabling call id
-     validation in OSP tokens.  The value is optional, call id validation
-     can be turned off by setting the value to 0 (No).  It may be used for
-     interoperability issues with some OSP clients sending invalid call ids
-     in Authorization Requests.
-   o Bug 4986 - changed return value for 'prepareallosproutes' from
-     0 - stop routing logic to 1 - true
-   o Bug 5039 - changed return value for 'preparenextosproute' when there is
-     no more routes from 0 - stop routing logic to -1 - false
-   o Bug 5039 - changed return value for 'preparenextosproute' when there is
-   o Bug 4893 - sequential routing (in failure_route[1]) now checks for code 
-     487 (Canceled) before trying the next OSP route.
-     Note - this check does not work when UAC cancels the call while SER is 
-     trying to connect to an unresponsive UAS, code 408 (time out) masks
-     code 487.  See new function 't_was_cancelled' in the 'tm' module.
-   o Bug 4892 - removed trailing binary chars from some log messages.
-   o Bug 4987 - fixed a compile time error on Solaris
-   o Bug 4946 - added README file
-
-September 26, 2005
-   o Bug 5094 - don't route the call if OSP token validation fails.
-   o Bug 5109 - send "100 Trying" message before requesting OSP routes.
-   o Bug 5111 - fixed typos in error messages.
-   o Bug 5153 - removed trailing binary chars from P-OSP-Auth-Token header
-                value.
-
-October 3, 2005
-   o Report OSP usage indications after the call set-up and tear down
-     transactions complete.
-
-October 17, 2005
-   o Report call set-up usage indication after receiving either 200 or 202.
-   o Report termination cause code for duration usage indications as 10,016
-     instead of 1,016.
-   o Improved error checking and logging.
-   o Bug 5366 - removed a memory leak in usage reporting logic.
-
-October 31, 2005
-   o Copied files from cvs.berlios.de:/cvsroot/osp-module to cvs.berlios.de:/cvsroot/ser
-
-2006 September 5
-   o Using BRAND_ROUTE approach to add route specific header to avoid sending
-     an OSP token to a non-OSP destination.
-   o Using called number in Request-Line for token validation and auth request.
-   o Sending DeviceInfo in "[x.x.x.x]" format in OSP AuthReq messages.
-   o Using fromtag in RR to report who releases the call first.
-   o Using AVP to add RR paramters for inserting OSP cookies.
-

+ 0 - 473
modules_s/osp/destination.c

@@ -1,473 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- *
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <string.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-#include "../../str.h"
-#include "../../dprint.h"
-#include "../../usr_avp.h"
-#include "destination.h"
-#include "usage.h"
-
-/* Name of AVP of OSP destination list */
-const str OSP_ORIGDEST_NAME = {"_osp_orig_dests_", 16};
-const str OSP_TERMDEST_NAME = {"_osp_term_dests_", 16};
-
-static int ospSaveDestination(osp_dest* dest, const str* name);
-static void ospRecordCode(int code, osp_dest* dest);
-static int ospIsToReportUsage(int code);
-
-/*
- * Initialize destination structure
- * param dest Destination data structure
- * return initialized destination sturcture
- */
-osp_dest* ospInitDestination(
-    osp_dest* dest)
-{
-    LOG(L_DBG, "osp: ospInitDestion\n");
-
-    memset(dest, 0, sizeof(osp_dest));
-
-    dest->callidsize = sizeof(dest->callid);
-    dest->tokensize = sizeof(dest->token);
-
-    LOG(L_DBG, "osp: callidsize '%d' tokensize '%d'\n", dest->callidsize, dest->tokensize);
-
-    return dest;
-}
-
-/* 
- * Save destination as an AVP
- *     name - OSP_ORIGDEST_NAME / OSP_TERMDEST_NAME
- *     value - osp_dest wrapped in a string
- * param dest Destination structure
- * param name Name of AVP
- * return 0 success, -1 failure
- */
-static int ospSaveDestination(
-    osp_dest* dest, 
-    const str* name)
-{
-    str wrapper;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospSaveDestination\n");
-
-    wrapper.s = (char*)dest;
-    wrapper.len = sizeof(osp_dest);
-
-    /* 
-     * add_avp will make a private copy of both the name and value in shared memory 
-     * which will be released by TM at the end of the transaction
-     */
-    if (add_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)*name, (int_str)wrapper) == 0) {
-        result = 0;
-        LOG(L_DBG, "osp: destination saved\n");
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to save destination\n");
-    }
-
-    return result;
-}
-
-/*
- * Save originate destination
- * param dest Originate destination structure
- * return 0 success, -1 failure
- */
-int ospSaveOrigDestination(
-    osp_dest* dest)
-{
-    LOG(L_DBG, "osp: ospSaveOrigDestination\n");
-
-    return ospSaveDestination(dest, &OSP_ORIGDEST_NAME);
-}
-
-/*
- * Save terminate destination
- * param dest Terminate destination structure
- * return 0 success, -1 failure
- */
-int ospSaveTermDestination(
-    osp_dest* dest)
-{
-    LOG(L_DBG, "osp: ospSaveTermDestination\n");
-
-    return ospSaveDestination(dest, &OSP_TERMDEST_NAME);
-}
-
-/* 
- * Check if there is an unused and supported originate destination from an AVP
- *     name - OSP_ORIGDEST_NAME
- *     value - osp_dest wrapped in a string
- *     search unused (used==0) & supported (support==1)
- * return 0 success, -1 failure
- */
-int ospCheckOrigDestination(void)
-{
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    struct search_state state;
-    osp_dest* dest = NULL;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospCheckOrigDestination\n");
-
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_NAME, &destval, &state);
-        destavp != NULL;
-        destavp = search_next_avp(&state, &destval))
-    {
-        /* OSP destintaion is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        if (dest->used == 0) {
-            if (dest->supported == 1) {
-                LOG(L_DBG, "osp: orig dest exist\n");
-                result = 0;
-                break;
-            } else {
-                LOG(L_DBG, "osp: destination does not been supported\n");
-            }
-        } else {
-            LOG(L_DBG, "osp: destination has already been used\n");
-        }
-    }
-
-    if (result == -1) {
-        LOG(L_DBG, "osp: there is not unused destination\n");
-    }
-
-    return result;
-}
-
-/* 
- * Retrieved an unused and supported originate destination from an AVP
- *     name - OSP_ORIGDEST_NAME
- *     value - osp_dest wrapped in a string
- *     There can be 0, 1 or more originate destinations. 
- *     Find the 1st unused destination (used==0) & supported (support==1),
- *     return it, and mark it as used (used==1).
- * return NULL on failure
- */
-osp_dest* ospGetNextOrigDestination(void)
-{
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    struct search_state state;
-    osp_dest* dest = NULL;
-    osp_dest* result = NULL;
-
-    LOG(L_DBG, "osp: ospGetNextOrigDestination\n");
-
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_NAME, &destval, &state);
-        destavp != NULL;
-        destavp = search_next_avp(&state, &destval))
-    {
-        /* OSP destintaion is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        if (dest->used == 0) {
-            if (dest->supported == 1) {
-                LOG(L_DBG, "osp: orig dest found\n");
-                dest->used = 1;
-                result = dest;
-                break;
-            } else {
-                /* Make it looks like used */
-                dest->used = 1;
-                /* 111 means wrong protocol */
-                dest->lastcode = 111;
-                LOG(L_DBG, "osp: destination does not been supported\n");
-            }
-        } else {
-            LOG(L_DBG, "osp: destination has already been used\n");
-        }
-    }
-
-    if (result == NULL) {
-        LOG(L_DBG, "osp: there is not unused destination\n");
-    }
-
-    return result;
-}
-
-/*
- * Retrieved the last used originate destination from an AVP
- *    name - OSP_ORIGDEST_NAME
- *    value - osp_dest wrapped in a string
- *    There can be 0, 1 or more destinations. 
- *    Find the last used destination (used==1) & supported (support==1),
- *    and return it.
- *    In normal condition, this one is the current destination. But it may
- *    be wrong for loop condition.
- *  return NULL on failure
- */
-osp_dest* ospGetLastOrigDestination(void)
-{
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    struct search_state state;
-    osp_dest* dest = NULL;
-    osp_dest* lastdest = NULL;
-
-    LOG(L_DBG, "osp: ospGetLastOrigDesintaion\n");
-
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_NAME, &destval, &state);
-        destavp != NULL;
-        destavp = search_next_avp(&state, &destval))
-    {
-        /* OSP destination is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        if (dest->used == 1) {
-            if (dest->supported == 1) {
-                lastdest = dest;
-                LOG(L_DBG, "osp: curent destination '%s'\n", lastdest->host);
-            }
-        } else {
-            break;
-        }
-    }
-
-    return lastdest;
-}
-
-/* 
- * Retrieved the terminate destination from an AVP
- *     name - OSP_TERMDEST_NAME
- *     value - osp_dest wrapped in a string
- *     There can be 0 or 1 term destinations. Find and return it.
- *  return NULL on failure (no terminate destination)
- */
-osp_dest* ospGetTermDestination(void)
-{
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    osp_dest* dest = NULL;
-
-    LOG(L_DBG, "osp: ospGetTermDestination\n");
-
-    destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_TERMDEST_NAME, &destval, NULL);
-
-    if (destavp) {
-        /* OSP destination is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        LOG(L_DBG, "osp: term dest found\n");
-    }
-
-    return dest;
-}
-
-/*
- * Record destination status
- * param code Destination status
- * param dest Destination
- */
-static void ospRecordCode(
-    int code, 
-    osp_dest* dest)
-{
-    LOG(L_DBG, "osp: ospRecordCode\n");
-
-    LOG(L_DBG, "osp: code '%d'\n", code);
-    dest->lastcode = code;
-
-    switch (code) {
-        case 100:
-            if (!dest->time100) {
-                dest->time100 = time(NULL);
-            } else {
-                LOG(L_DBG, "osp: 100 already recorded\n");
-            }
-            break;
-        case 180:
-        case 181:
-        case 182:
-        case 183:
-            if (!dest->time180) {
-                dest->time180 = time(NULL);
-            } else {
-                LOG(L_DBG, "osp: 180, 181, 182 or 183 allready recorded\n");
-            }
-            break;
-        case 200:
-        case 202:
-            if (!dest->time200) {
-                dest->time200 = time(NULL);
-            } else {
-                LOG(L_DBG, "osp: 200 or 202 allready recorded\n");
-            }
-            break;
-        default:
-            LOG(L_DBG, "osp: will not record time for '%d'\n", code);
-    }
-}
-
-/*
- * Check destination status for reporting usage
- * param code Destination status
- * return 1 should report, 0 should not report
- */
-static int ospIsToReportUsage(
-    int code)
-{
-    int istime = 0;
-
-    LOG(L_DBG, "osp: ospIsToReportUsage\n");
-
-    LOG(L_DBG, "osp: code '%d'\n", code);
-    if (code >= 200) {
-        istime = 1;
-    }
-
-    return istime;
-}
-
-/*
- * Report call setup usage for both client and server side
- * param clientcode Client status
- * param servercode Server status
- */
-void ospRecordEvent(
-    int clientcode, 
-    int servercode)
-{
-    osp_dest* dest;
-
-    LOG(L_DBG, "osp: ospRecordEvent\n");
-
-    LOG(L_DBG, "osp: client status '%d'\n", clientcode);
-    if ((clientcode != 0) && (dest = ospGetLastOrigDestination())) {
-        ospRecordCode(clientcode, dest);
-
-        if (ospIsToReportUsage(servercode) == 1) {
-            ospReportOrigSetupUsage();
-        }
-    }
-
-    LOG(L_DBG, "osp: server status '%d'\n", servercode);
-    if ((servercode != 0) && (dest = ospGetTermDestination())) {
-        ospRecordCode(servercode, dest);
-
-        if (ospIsToReportUsage(servercode) == 1) {
-            ospReportTermSetupUsage();
-        }
-    }
-}
-
-/*
- * Dump destination information
- * param dest Destination
- */
-void ospDumpDestination(
-    osp_dest* dest)
-{
-    LOG(L_DBG, "osp: dest->host..........'%s'\n", dest->host);
-    LOG(L_DBG, "osp: dest->used..........'%d'\n", dest->used);
-    LOG(L_DBG, "osp: dest->lastcode......'%d'\n", dest->lastcode);
-    LOG(L_DBG, "osp: dest->time100.......'%d'\n", (unsigned int)dest->time100);
-    LOG(L_DBG, "osp: dest->time180.......'%d'\n", (unsigned int)dest->time180);
-    LOG(L_DBG, "osp: dest->time200.......'%d'\n", (unsigned int)dest->time200);
-}
-
-/*
- * Dump all destination information
- */
-void ospDumpAllDestination(void)
-{
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    struct search_state state;
-    osp_dest* dest = NULL;
-    int count = 0;
-
-    LOG(L_DBG, "osp: ospDumpAllDestination\n");
-
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_NAME, &destval, &state);
-        destavp != NULL;
-        destavp = search_next_avp(&state, &destval))
-    {
-        /* OSP destination is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        LOG(L_DBG, "osp: ....originate '%d'....\n", count++);
-
-        ospDumpDestination(dest);
-    }
-    if (count == 0) {
-        LOG(L_DBG, "osp: there is not originate destination AVP\n");
-    }
-
-    destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_TERMDEST_NAME, &destval, NULL);
-
-    if (destavp) {
-        /* OSP destination is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        LOG(L_DBG, "osp: ....terminate....\n");
-
-        ospDumpDestination(dest);
-    } else {
-        LOG(L_DBG, "osp: there is not terminate destination AVP\n");
-    }
-}
-
-/*
- * Convert address to "[x.x.x.x]" or "host.domain" format
- * param src Source address
- * param dst Destination address
- * param buffersize Size of dst buffer
- */
-void ospConvertAddress(
-    char* src,
-    char* dst,
-    int buffersize)
-{
-    struct in_addr inp;
-
-    LOG(L_DBG, "osp: ospConvertAddress\n");
-
-    if (inet_aton(src, &inp) != 0) {
-        snprintf(dst, buffersize, "[%s]", src);
-    } else {
-        snprintf(dst, buffersize, "%s", src);
-    }
-}
-

+ 0 - 84
modules_s/osp/destination.h

@@ -1,84 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_DESTINATION_H_
-#define _OSP_MOD_DESTINATION_H_
-
-#include <time.h>
-#include "osp_mod.h"
-
-typedef struct _osp_dest {
-    char validafter[OSP_STRBUF_SIZE];
-    char validuntil[OSP_STRBUF_SIZE];
-    char callid[OSP_STRBUF_SIZE];
-    char called[OSP_STRBUF_SIZE];
-    char calling[OSP_STRBUF_SIZE];
-    char source[OSP_STRBUF_SIZE];
-    char srcdev[OSP_STRBUF_SIZE];
-    char host[OSP_STRBUF_SIZE];
-    char destdev[OSP_STRBUF_SIZE];
-    char networkid[OSP_STRBUF_SIZE];
-    unsigned char token[OSP_TOKENBUF_SIZE];
-    unsigned int callidsize;
-    unsigned int tokensize;
-    unsigned int timelimit;
-    int lastcode;
-    time_t authtime;
-    time_t time100;
-    time_t time180;
-    time_t time200;
-    int type;
-    unsigned long long transid;
-    int supported;
-    int used;
-    int reported;
-    unsigned int destinationCount;
-    char origcalled[OSP_STRBUF_SIZE];
-} osp_dest;
-
-osp_dest* ospInitDestination(osp_dest* dest);
-int ospSaveOrigDestination(osp_dest* dest);
-int ospSaveTermDestination(osp_dest* dest);
-int ospCheckOrigDestination(void);
-osp_dest* ospGetNextOrigDestination(void);
-osp_dest* ospGetLastOrigDestination(void);
-osp_dest* ospGetTermDestination(void);
-void ospRecordEvent(int clientcode, int servercode);
-void ospDumpDestination(osp_dest* dest);
-void ospDumpAllDestination(void);
-void ospConvertAddress(char* src, char* dst, int buffersize);
-
-#endif /* _OSP_MOD_DESTINATION_H_ */
-

+ 0 - 4
modules_s/osp/doc/Makefile

@@ -1,4 +0,0 @@
-docs = osp.xml
-
-docbook_dir=../../../docbook
-include $(docbook_dir)/Makefile.module

+ 0 - 54
modules_s/osp/doc/osp.xml

@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" 
-   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
-
-<!ENTITY user SYSTEM "osp_user.xml">
-<!ENTITY devel SYSTEM "osp_devel.xml">
-<!ENTITY faq SYSTEM "osp_faq.xml">
-
-<!-- Include general documentation entities -->
-<!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
-%docentities;
-
-]>
-
-<book>
-  <bookinfo>
-    <title>OSP Module for Secure, Multi-Lateral Peering</title>
-    <productname class="trade">&sername;</productname>
-    <authorgroup>
-      <author>
-        <firstname>Ulrich</firstname>
-        <surname>Abend</surname>
-        <affiliation>
-          <orgname>&fhg;</orgname>
-          <address><email>[email protected]</email></address>
-        </affiliation>
-      </author>
-      <editor>
-        <firstname>Di-Shi</firstname>
-        <surname>Sun</surname>
-        <affiliation>
-          <orgname>TransNexus, Inc.</orgname>
-          <address><email>[email protected]</email></address>
-        </affiliation>
-      </editor>
-    </authorgroup>
-    <copyright>
-      <year>2003</year>
-      <holder>&fhg;</holder>
-    </copyright>
-    <revhistory>
-      <revision>
-        <revnumber>$Revision$</revnumber>
-        <date>$Date$</date>
-      </revision>
-    </revhistory>
-  </bookinfo>
-  <toc></toc>
-
-  &user;
-  &devel;
-  &faq;
-
-</book>

+ 0 - 20
modules_s/osp/doc/osp_devel.xml

@@ -1,20 +0,0 @@
-<!-- OSP Module Developer's Guide -->
-
-<chapter>
-  <chapterinfo>
-    <revhistory>
-      <revision>
-        <revnumber>$Revision$</revnumber>
-        <date>$Date$</date>
-      </revision>
-    </revhistory>
-  </chapterinfo>
-  <title>Developer's Guide</title>
-  <para>The functions of the OSP modules are not used by other SER modules.</para>
-</chapter>
-
-<!-- Keep this element at the end of the file
-Local Variables:
-xml-parent-document: ("osp.xml" "book" "chapter")
-End:
--->

+ 0 - 50
modules_s/osp/doc/osp_faq.xml

@@ -1,50 +0,0 @@
-<!-- OSP Module FAQ -->
-
-<chapter>
-  <chapterinfo>
-    <revhistory>
-      <revision>
-        <revnumber>$Revision$</revnumber>
-        <date>$Date$</date>
-      </revision>
-    </revhistory>
-  </chapterinfo>
-  <title>Frequently Asked Questions</title>
-  <qandaset>
-    <qandaentry>
-      <question><para>What platforms does this module work on?</para></question>
-      <answer><para>The module has been implemented using Linux, the underlying toolkit and the module code itself should compile and work on Solaris, *BSD, and probably most other unix platforms with ssl and pthreads available, but the OSP Module has only been tested Linux.</para></answer>
-    </qandaentry>
-    <qandaentry>
-      <question><para>Where can I get more information on this module?</para></question>
-      <answer><para>Please see http://www.iptel.org/views/moduledocs/ or post a message on the SER mailing list.</para></answer>
-    </qandaentry>
-    <qandaentry>
-      <question><para>Where can I get more information on OSP?</para></question>
-      <answer><para>The OSP technical specification (ETSI TS 101 321) may be obtained from www.etsi.org.  You can also post a message on the OSP Toolkit mailing list at https://lists.sourceforge.net/lists/listinfo/osp-toolkit-client.</para></answer>
-    </qandaentry>
-    <qandaentry>
-      <question><para>How do I obtain an OSP server for testing?</para></question>
-      <answer>
-        <para>OSP peering servers are available from the following sources:</para>
-        <itemizedlist>
-          <listitem><para>OpenOSP is an OSP server reference implementation created by Cisco Systems and available at http://www.vovida.org/applications/downloads/openosp/</para></listitem>
-          <listitem><para>RAMS is an open source, java based OSP server project available from http://sourceforge.net/projects/rams/</para></listitem>
-          <listitem><para>A free version of the commercial TransNexus OSP peering server is available at www.transnexus.com.</para></listitem>
-        </itemizedlist>
-      </answer>
-    </qandaentry>
-    <qandaentry>
-      <question><para>How are the exported functions used by the OSP module?</para></question>
-      <answer>
-        <para>See sample-osp-ser.cfg in modules/osp/etc for examples</para>
-      </answer>
-    </qandaentry>
-  </qandaset>
-</chapter>
-
-<!-- Keep this element at the end of the file
-Local Variables:
-xml-parent-document: ("osp.xml" "Book" "chapter")
-End:
--->

+ 0 - 369
modules_s/osp/doc/osp_user.xml

@@ -1,369 +0,0 @@
-<!-- OSP Module User's Guide -->
-
-<chapter>
-  <chapterinfo>
-    <revhistory>
-      <revision>
-        <revnumber>$Revision$</revnumber>
-        <date>$Date$</date>
-      </revision>
-    </revhistory>
-  </chapterinfo>
-  <title>User's Guide</title>
-  <section>
-    <title>Overview</title>
-    <para>The OSP module enables SER to support secure, multi-lateral peering using the OSP standard defined by ETSI (TS 101 321 V4.1.1). This module will enable your SER to:</para>
-    <itemizedlist>
-      <listitem>
-        <para>Send a peering authorization request to a peering server.</para>
-      </listitem>
-      <listitem>
-        <para>Validate a digitally signed peering authorization token received in a SIP INVITE message.</para>
-      </listitem>
-      <listitem>
-        <para>Report usage information to a peering server.</para>
-      </listitem>
-    </itemizedlist>
-  </section>
-  <section>
-    <title>Dependencies</title>
-    <para>The OSP module depends on the following modules which must be loaded before the OSP module.</para>
-    <itemizedlist>
-      <listitem>
-        <para><emphasis>sl</emphasis> -- stateless replier</para>
-      </listitem>
-      <listitem>
-        <para><emphasis>tm</emphasis> -- stateful processing</para>
-      </listitem>
-      <listitem>
-        <para><emphasis>rr</emphasis> -- Record-Route/Route operation</para>
-      </listitem>
-      <listitem>
-        <para><emphasis>textops</emphasis> -- text based operation</para>
-      </listitem>
-      <listitem>
-        <para><emphasis>avpops</emphasis> -- AVP operation</para>
-      </listitem>
-      <listitem>
-        <para><emphasis>OSP Toolkit</emphasis> -- The OSP Toolkit, available from http://sourceforge.net/projects/osp-toolkit, must be built before building SER with the OSP Module.  For instructions on building SER with the OSP Toolkit, see http://www.transnexus.com/White%20Papers/Multi-Lateral_Peering_with_SER_V2.0.x.pdf</para>
-      </listitem>
-    </itemizedlist>
-  </section>
-  <section>
-    <title>Exported Parameters</title>
-    <section>
-      <title><varname>sp1_uri</varname>, <varname>sp2_uri</varname>, ..., <varname>sp16_uri</varname></title>
-      <para>These sp_uri (string) parameters define peering servers to be used for requesting peering authorization and routing information. At least one peering server must be configured. Others are required only if there are more than one peering servers. Each peering server address takes the form of a standard URL, and consists of up to four components:</para>
-      <itemizedlist>
-        <listitem>
-          <para>An optional indication of the protocol to be used for communicating with the peering server. Both HTTP and HTTP secured with SSL/TLS are supported and are indicated by "http://" and "https://" respectively. If the protocol is not explicitly indicated, the SER defaults to HTTP secured with SSL.</para>
-        </listitem>
-        <listitem>
-          <para>The Internet domain name for the peering server. An IP address may also be used, provided it is enclosed in square brackets such as [172.16.1.1].</para>
-        </listitem>
-        <listitem>
-          <para>An optional TCP port number for communicating with the peering server. If the port number is omitted, the SER defaults to port 1080 (for HTTP) or port 1443 (for HTTP secured with SSL).</para>
-          <para>The uniform resource identifier for requests to the peering server. This component is not optional and must be included.</para>
-        </listitem>
-      </itemizedlist>
-      <example>
-        <title>Setting the OSP servers</title>
-        <programlisting format="linespecific">
-modparam("osp","sp1_uri","http://osptestserver.transnexus.com:1080/osp")
-modparam("osp","sp2_uri","https://[1.2.3.4]:1443/osp")
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>device_ip</varname></title>
-      <para>The device_ip (string) is a recommended parameter that explicitly defines the IP address of SER in a peering request message (as SourceAlternate type=transport).  The IP address must be in brackets as shown in the example below.</para>
-      <example>
-        <title>Setting the device IP address</title>
-        <programlisting format="linespecific">
-modparam("osp","device_ip","[1.1.1.1]")
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>token_format</varname></title>
-      <para>When SER receives a SIP INVITE with a peering token, the OSP Module will validate the token to determine whether or not the call has been authorized by a peering server. Peering tokens may, or may not, be digitally signed. The token format (integer) parameter defines if SER will validate signed or unsigned tokens or both. The values for token format are defined below. The default value is 2.</para>
-      <para>0 - Validate only signed tokens. Calls with valid signed tokens are allowed.</para>
-      <para>1 - Validate only unsigned tokens. Calls with valid unsigned tokens are allowed.</para>
-      <para>2 - Validate both signed and unsigned tokens are allowed. Calls with valid tokens are allowed.</para>
-      <example>
-        <title>Setting the token format</title>
-        <programlisting format="linespecific">
-modparam("osp","token_format",2)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>private_key</varname>, <varname>local_certificate</varname>, <varname>ca_certificates</varname></title>
-      <para>These parameters identify files are used for validating peering authorization tokens and establishing a secure channel between SER and a peering server using SSL.  The files are generated using the 'Enroll' utility from the OSP Toolkit. By default, the proxy will look for pkey.pem, localcert.pem, and cacart_0.pem in the default configuration directory. The default config directory is set at compile time using CFG_DIR and defaults to /usr/local/etc/ser/. The files may be copied to the expected file location or the parameters below may be changed.</para>
-      <example>
-        <title>Set authorization files</title>
-        <para>If the default CFG_DIR value was used at compile time, the files will be loaded from:</para>
-        <programlisting format="linespecific">
-modparam("osp","private_key","/usr/local/etc/ser/pkey.pem")
-modparam("osp","local_certificate","/usr/local/etc/ser/localcert.pem")
-modparam("osp","ca_certificates","/usr/local/etc/ser/cacert.pem")
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>sp1_weight</varname>, <varname>sp2_weight</varname>, ..., <varname>sp16_weight</varname></title>
-      <para>These sp_weight (integer) parameters are used for load balancing peering requests to peering servers. These parameters are most effective when configured as factors of 1000. For example, if sp1_uri should manage twice the traffic load of sp2_uri, then set sp1_weight to 2000 and sp2_weight to 1000. Shared load balancing between peering servers is recommended. However, peering servers can be configured as primary and backup by assigning a sp_weight of 0 to the primary server and a non-zero sp_weight to the back-up server. The default values for sp1_weight and sp2_weight are 1000.</para>
-      <example>
-        <title>Setting the OSP server weights</title>
-        <programlisting format="linespecific">
-modparam("osp","sp1_weight",1000)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>device_port</varname></title>
-      <para>The device_port (string) parameter is an optional field which includes the SIP port being used by SER in the peering request (as SourceAlternate type=network) to the peering server. If is not configured, this information is not included in the peering request. This field is useful if multiple SERs are running on the same Linux computer since it enables the peering server to administer different peering policies based on different SIP proxies.  This parameter has not been implemented yet.</para>
-      <example>
-        <title>Setting the device port</title>
-        <programlisting format="linespecific">
-modparam("osp","device_port","5060")
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>enable_crypto_hardware_support</varname></title>
-      <para>The enable_crypto_hardware_support (integer) parameter is used to set the cryptographic hardware acceleration engine in the openssl library. The default value is 0 (no crypto hardware is present). If crypto hardware is used, the value should be set to 1.</para>
-      <example>
-        <title>Setting the hardware support</title>
-        <programlisting format="linespecific">
-modparam("osp","enable_crypto_hardware_support",0)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>ssl_lifetime</varname></title>
-      <para>The ssl_lifetime (integer) parameter defines the lifetime, in seconds, of a single SSL session key. Once this time limit is exceeded, the OSP Module will negotiate a new session key. Communication exchanges in progress will not be interrupted when this time limit expires. This is an optional field with default value is 200 seconds.</para>
-      <example>
-        <title>Setting the ssl lifetime</title>
-        <programlisting format="linespecific">
-modparam("osp","ssl_lifetime",200)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>persistence</varname></title>
-      <para>The persistence (integer) parameter defines the time, in seconds, that an HTTP connection should be maintained after the completion of a communication exchange. The OSP Module will maintain the connection for this time period in anticipation of future communication exchanges to the same peering server.</para>
-      <example>
-        <title>Setting the persistence</title>
-        <programlisting format="linespecific">
-modparam("osp","persistence",1000)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>retry_delay</varname></title>
-      <para>The retry_delay (integer) parameter defines the time, in seconds, between retrying connection attempts to an OSP peering server. After exhausting all peering servers the OSP Module will delay for this amount of time before resuming connection attempts. This is an optional field with default value is 1 second.</para> 
-      <example>
-        <title>Setting the retry delay</title>
-        <programlisting format="linespecific">
-modparam("osp","retry_delay",1)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>retry_limit</varname></title>
-      <para>The retry_limit (integer) parameter defines the maximum number of retries for connection attempts to a peering server. If no connection is established after this many retry attempts to all peering servers, the OSP Module will cease connection attempts and return appropriate error codes. This number does not count the initial connection attempt, so that a retry_limit of 1 will result in a total of two connection attempts to every peering server. The default value is 2.</para> 
-      <example>
-        <title>Setting the retry limit</title>
-        <programlisting format="linespecific">
-modparam("osp","retry_limit",2)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>timeout</varname></title>
-      <para>The timeout (integer) parameter defines the maximum time in milliseconds, to wait for a response from a peering server. If no response is received within this time, the current connection is aborted and the OSP Module attempts to contact the next peering server. The default value is 10 seconds.</para> 
-      <example>
-        <title>Setting the timeout</title>
-        <programlisting format="linespecific">
-modparam("osp","timeout",10)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>max_destinations</varname></title>
-      <para>The max_destinations (integer) parameter defines the maximum number of destinations that SER requests the peering server to return in a peering response. The default value is 5.</para>
-      <example>
-        <title>Setting the number of destination</title>
-        <programlisting format="linespecific">
-modparam("osp","max_destinations",5)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>validate_call_id</varname></title>
-      <para>The validate_call_id (integer) parameter instructs the OSP module to validate call id in the peering token. If this value is set to 1, the OSP Module validates that the call id in the SIP INVITE message matches the call id in the peering token. If they do not match the INVITE is rejected. If this value is set to 0, the OSP Module will not validate the call id in the peering token. The default value is 1.</para>
-      <example>
-        <title>Instructing the module to validate call id</title>
-        <programlisting format="linespecific">
-modparam("osp","validate_call_id",1)
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><varname>use_rpid_for_calling_number</varname></title>
-      <para>The use_rpid_for_calling_number(integer) parameter instructs the OSP module to use the calling number in the Remote-Party-ID of the SIP INVITE message. If this value is set to 1, the OSP Module uses the calling number in the Reomte-Party-ID header of the INVITE message when a Remote-Party-ID exists. If this value is set to 0, the OSP Module will use the calling number in the From header of the INVITE message. The default value is 1.</para>
-      <example>
-        <title>Instructing the module to use calling number in Remote-Party-ID</title>
-        <programlisting format="linespecific">
-modparam("osp","use_rpid_calling_number",1)
-        </programlisting>
-      </example>
-    </section>
-  </section>
-  <section>
-    <title>Exported Functions</title>
-    <section>
-      <title><function moreinfo="none">checkospheader()</function></title>
-      <para>This function checks for the existence of the OSP-Auth-Token header field.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>checkospheader usage</title>
-        <programlisting format="linespecific">
-...
-if (checkospheader()) {
-  log("OSP header field found.\n");
-} else {
-  log("no OSP header field present\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">validateospheader()</function></title>
-      <para>This function validates an OSP-Token specified in the OSP-Auth-Tokenheader field of the SIP message. If a peering token is present, it will be validated locally. If no OSP header is found or the header token is invalid or expired, -1 is returned; on successful validation 1 is returned.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>validateospheader usage</title>
-        <programlisting format="linespecific">
-...
-if (validateospheader()) {
-  log("valid OSP header found\n");
-} else {
-  log("OSP header not found, invalid or expired\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">requestosprouting()</function></title>
-      <para>This function launches a query to the peering server requesting the IP address of one or more destination peers serving the called party. If destination peers are available, the peering server will return the IP address and a peering authorization token for each destination peer. The OSP-Auth-Token Header field is inserted into the SIP message and the SIP uri is rewritten to the IP address of destination peer provided by the peering server.</para>
-      <para>The address of the called party must be a valid E164 number, otherwise this function returns -1. If the transaction was accepted by the peering server, the uri is being rewritten and 1 returned, on errors (peering servers are not available, authentication failed or there is no route to destination or the route is blocked) -1 is returned.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>requestosprouting usage</title>
-        <programlisting format="linespecific">
-...
-if (requestosprouting()) {
-  log("successfully queried OSP server, now relaying call\n");
-} else {
-  log("Authorization request was rejected from OSP server\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">prepareospfirstroute()</function></title>
-      <para>This function tries to prepare the INVITE to be forwarded or redirected using the first destination in the list returned by the peering server. If the route could not be prepared, the function returns 'FALSE' back to the script, which can then decide how to handle the failure.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>prepareospfirstroute usage</title>
-        <programlisting format="linespecific">
-...
-if (prepareospfirstroute ()) {
-  log("successfully prepared the first route, now relaying call\n");
-} else {
-  log("could not prepare the route. The first destination was blocked\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">prepareosprnextoute()</function></title>
-      <para>Once the call could not be completed through the first destination, this function tries to prepare the INVITE message using the next destination in the list returned by the peering Server. If it succeeds in preparing the route, the message is either redirected or relayed on (using the t_relay call), or else the function returns 'FALSE' back to the script, which can then decide how to handle the failure.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>prepareospnextroute usage</title>
-        <programlisting format="linespecific">
-...
-if (prepareospnextroute ()) {
-  log("successfully prepared the next route, now relaying call\n");
-} else {
-  log("could not prepare the route. No next destination available\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">appendospheaders()</function></title>
-      <para>This function is used to append route specific OSP headers. Before calling appendospheaders, prepareospfirst/nextroute should be called.</para>
-      <para>This function can be used from BRANCH_ROUTE.</para> 
-      <example>
-        <title>appendospheaders usage</title>
-        <programlisting format="linespecific">
-...
-branch_route[1] {
-  log("Prepare route specific OSP information\n");
-  appendospheaders();
-}
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">prepareallosproute()</function></title>
-      <para>This function tries to prepare all the routes in the list returned by the peering server. The message is then either forked off or redirected to the destination. If unsuccessful in preparing the routes a SIP 500 is sent back and a trace message is logged.</para>
-      <para>This function can be used from REQUEST_ROUTE and FAILURE_ROUTE.</para> 
-      <example>
-        <title>prepareallosproute usage</title>
-        <programlisting format="linespecific">
-...
-if (prepareallosproute()) {
-  log("Routes are prepared, now either forking or redirecting the call\n");
-} else {
-  log("Could not prepare the routes. No destination available\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-    <section>
-      <title><function moreinfo="none">reportospusage()</function></title>
-      <para>This function should be called after receiving a BYE message. If the message contains an OSP cookie, the function will forward originating and/or terminating duration usage information to a peering server. The function returns TRUE if the BYE includes an OSP cookie. The actual usage message will be send on a different thread and will not delay BYE processing. The function should be called before relaying the message.</para>
-      <para>This function can be used from REQUEST_ROUTE.</para> 
-      <example>
-        <title>reportospusage usage</title>
-        <programlisting format="linespecific">
-...
-if (reportospusage ()) {
-  log("OSP call duration usage will be reported\n");
-} else {
-  log("The BYE message does not include OSP information, it was not authorized by an OSP server\n");
-};
-...
-        </programlisting>
-      </example>
-    </section>
-  </section>
-</chapter>
-
-<!-- Keep this element at the end of the file
-Local Variables:
-xml-parent-document: ("osp.xml" "Book" "chapter")
-End:
--->

+ 0 - 10
modules_s/osp/etc/cacert_0.pem

@@ -1,10 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIBYDCCAQoCAQEwDQYJKoZIhvcNAQEEBQAwOzElMCMGA1UEAxMcb3NwdGVzdHNl
-cnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMB4XDTAyMDIw
-NDE4MjU1MloXDTEyMDIwMzE4MjU1MlowOzElMCMGA1UEAxMcb3NwdGVzdHNlcnZl
-ci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQU2VydmVyMFwwDQYJKoZIhvcN
-AQEBBQADSwAwSAJBAPGeGwV41EIhX0jEDFLRXQhDEr50OUQPq+f55VwQd0TQNts0
-6BP29+UiNdRW3c3IRHdZcJdC1Cg68ME9cgeq0h8CAwEAATANBgkqhkiG9w0BAQQF
-AANBAGkzBSj1EnnmUxbaiG1N4xjIuLAWydun7o3bFk2tV8dBIhnuh445obYyk1En
-Q27kI7eACCILBZqi2MHDOIMnoN0=
------END CERTIFICATE-----

+ 0 - 10
modules_s/osp/etc/localcert.pem

@@ -1,10 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIBeTCCASMCEHqkOHVRRWr+1COq3CR/xsowDQYJKoZIhvcNAQEEBQAwOzElMCMG
-A1UEAxMcb3NwdGVzdHNlcnZlci50cmFuc25leHVzLmNvbTESMBAGA1UEChMJT1NQ
-U2VydmVyMB4XDTA1MDYyMzAwMjkxOFoXDTA2MDYyNDAwMjkxOFowRTELMAkGA1UE
-BhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdp
-ZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCvLeZfj1G0wuJb
-8JTcVeZaZftncEmRluOnaME3ustd918lRMDYokZmtmDZN8SrP0yd1pfVqZ7NkmBA
-CbBX0k7pAgMBAAEwDQYJKoZIhvcNAQEEBQADQQDnV8QNFVVJx/+7IselU0wsepqM
-urivXZzuxOmTEmTVDzCJx1xhA8jd3vGAj7XDIYiPub1PV23eY5a2ARJuw5w9
------END CERTIFICATE-----

+ 0 - 9
modules_s/osp/etc/pkey.pem

@@ -1,9 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIBOgIBAAJBAK8t5l+PUbTC4lvwlNxV5lpl+2dwSZGW46dowTe6y133XyVEwNii
-Rma2YNk3xKs/TJ3Wl9Wpns2SYEAJsFfSTukCAwEAAQJAPz13vCm2GmZ8Zyp74usT
-xLCqSJZNyMRLHQWBM0g44Iuy4wE3vpi7Wq+xYuSOH2mu4OddnxswCP4QhaXVQavT
-AQIhAOBVCKXtppEw9UaOBL4vW0Ed/6EA/1D8hDW6St0h7EXJAiEAx+iRmZKhJD6V
-T84dtX5ZYNVk3j3dAcIOovpzUj9a0CECIEduTCapmZQ5xqAEsLXuVlxRtQgLTUD4
-ZxDElPn8x0MhAiBE2HlcND0+qDbvtwJQQOUzDgqg5xk3w8capboVdzAlQQIhAMC+
-lDL7+gDYkNAft5Mu+NObJmQs4Cr+DkDFsKqoxqrm
------END RSA PRIVATE KEY-----

+ 0 - 463
modules_s/osp/etc/sample-osp-ser.cfg

@@ -1,463 +0,0 @@
-
-debug=3         # debug level (cmd line: -dddddddddd)
-fork=yes
-log_stderror=no # (cmd line: -E)
-sip_warning=no
-
-/* Uncomment these lines to enter debugging mode 
-# fork=no
-# log_stderror=yes
-*/
-
-check_via=no    # (cmd. line: -v)
-dns=no          # (cmd. line: -r)
-rev_dns=no      # (cmd. line: -R)
-port=5060
-children=20
-
-# ------------------ module loading ----------------------------------
-loadmodule "/usr/local/lib/ser/modules/sl.so"
-loadmodule "/usr/local/lib/ser/modules/tm.so"
-loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
-loadmodule "/usr/local/lib/ser/modules/rr.so"
-loadmodule "/usr/local/lib/ser/modules/textops.so"
-loadmodule "/usr/local/lib/ser/modules/ctl.so"
-loadmodule "/usr/local/lib/ser/modules/usrloc.so"
-loadmodule "/usr/local/lib/ser/modules/registrar.so"
-loadmodule "/usr/local/lib/ser/modules/avpops.so"
-loadmodule "/usr/local/lib/ser/modules/fifo.so"
-loadmodule "/usr/local/lib/ser/modules/options.so"
-loadmodule "/usr/local/lib/ser/modules/xlog.so"
-# Load OSP module
-loadmodule "/usr/local/lib/ser/modules/osp.so"
-
-# ----------------- setting module-specific parameters ---------------
-
-#
-# PEERING PARAMETERS:
-# ===================
-# This section contains OSP parameters that users may need to configure for multi-lateral
-# peering. (sp1_uri must be configured.) Additional detail on OSP Module parameters and
-# functions is provided in the "OSP Module for Secure, Multi-Lateral Peering" document
-# located at:http://developer.berlios.de/docman/?group_id=3799
-#
-# Configure Peering Servers:
-# ==========================
-# SER can be configured to query two peering servers for routing information and peering 
-# authorization tokens using the sp1_uri and sp2_uri parameters. A configuration for sp1_uri
-# is required, configuring sp2_uri is optional. The peering server address should be 
-# configured as a standard URL beginning with either http:// or https:// followed by the 
-# domain name of the OSP server or the IP address enclosed in brackets. The domain name 
-# or IP address should be followed by the peering server TCP port number and uniform 
-# resource identifier. Below are example configurations.
-#
-modparam("osp", "sp1_uri", "http://osptestserver.transnexus.com:1080/osp")
-# modparam("osp", "sp2_uri", "https://[1.2.3.4]:1443/osp")
-
-#
-# SER IP Address
-# ==============
-# device_ip is a recommended parameter that explicitly defines the IP address of SER in 
-# a peering request message (as SourceAlternate type=transport).  The IP address must 
-# be in brackets as shown in the example below.
-#
-# modparam("osp", "device_ip", "[1.1.1.1]")
-
-#
-# Peering Token Validation
-# ========================
-# When SER receives a SIP INVITE with a peering token, the OSP Module will validate the token to
-# determine whether or not the call has been authorized by a peering server.  Peering tokens may,
-# or may not, be digitally signed.  This parameter defines if SER will validate signed or unsigned
-# tokens or both. The values for "token format" are defined below.  The default value is 2.
-#
-# 0 - Validate only signed tokens.  Calls with valid signed tokens are allowed.
-# 1 - Validate only unsigned tokens.  Calls with valid unsigned tokens are allowed.
-# 2 - Validate both signed and unsigned tokens are allowed.  Calls with valid tokens are allowed.
-#
-# modparam("osp", "token_format", 2)
-
-#
-# Crypto files from Peering Server Enrollment
-# ===========================================
-# These parameters identify crypto files used for validating peering authorization tokens
-# and establishing a secure channel between SER and a peering server using SSL.  The files are 
-# generated using the 'Enroll' utility from the OSP toolkit.  By default, the proxy will look
-# for pkey.pem, localcert.pem, and cacart_0.pem in the default configuration directory. 
-# The default config directory is set at compile time using CFG_DIR and defaults to 
-# /usr/local/etc/ser/.  The files may be copied to the expected file location or the 
-# parameters below may be changed.
-#
-# If the default CFG_DIR value was used at compile time, the files will be loaded from:
-# modparam("osp", "private_key", "/usr/local/etc/ser/pkey.pem")
-# modparam("osp", "local_certificate", "/usr/local/etc/ser/localcert.pem")
-# modparam("osp", "ca_certificates", "/usr/local/etc/ser/cacert_0.pem")
-
-#
-# Use Remote-Party-ID for calling number
-# ===========================================
-# This parameter is used to tell OSP module if the calling number should be obtained from RPID header. 
-# The default value is 1.
-#
-# 0 - OSP module will use the calling number in From header.
-# 1 - OSP module will use the calling number in RPID header if a RPID header exists.
-#
-# modparam("osp", "use_rpid_for_calling_number", 1)
-
-#
-# URI Format for Redirection Messages
-# ===========================================
-# This parameter is used to tell OSP module which URI format should be used for redirection messages.
-# The default value is 0.
-#
-# 0 - "[email protected]"
-# 1 - "<[email protected]>". This is for Cisco 2600 IP-IP gateway.
-#
-# modparam("osp", "redirection_uri_format", 0)
-
-# listen on the "standard" fifo for backward compatibility
-modparam("ctl", "fifo", "fifo:/tmp/ser_fifo")
-
-# -- usrloc params --
-modparam("usrloc", "db_mode", 0)
-
-# -- rr params --
-avpflags dialog_cookie;
-
-# add value to ;lr param to make some broken UAs happy
-modparam("rr", "enable_full_lr", 1)
-
-# enable append_fromtag, request's from-tag is appended to record-route; 
-# that's useful for understanding whether subsequent requests (such as BYE) come from
-# caller (route's from-tag==BYE's from-tag) or callee (route's from-tag==BYE's to-tag) 
-modparam("rr", "append_fromtag", 1)
-
-# -- tm params --
-# Timer which hits if no final reply for a request or ACK for a
-# negative INVITE reply arrives (in seconds).  For example - UA server is off-line.
-# In other words, if the proxy does not receive a response to an Invite before this
-# timer expires, the proxy will retry the call and send an Invite to the next VoIP
-# destination in the routing list.
-modparam("tm", "fr_timer", 5000)
-
-# Timer which hits if no final reply for an INVITE arrives after
-# a provisional message was received (in seconds).
-# For example - user is not picking up the phone
-modparam("tm", "fr_inv_timer", 30000)
-
-
-# -------------------------  request routing logic -------------------
-
-# main routing logic
-route{
-    xlog("L_INFO", "----ROUTE: Route IN - M=%rm RURI=%ru F=%fu T=%tu IP=%si ID=$ci\n");
-
-    # initial sanity checks
-    if (!mf_process_maxfwd_header("10")) {
-        xlog("L_WARN", "----ROUTE: Too many hops, $rm from '%fu' to '%tu'\n");
-        sl_send_reply("483", "Too Many Hops");
-        break;
-    };
-
-    if (msg:len >= max_len) {
-        xlog("L_WARN", "----ROUTE: Message too big, $rm from '%fu' to '%tu'\n");
-        sl_send_reply("513", "Message Too Big");
-        break;
-    };
-
-    # we record-route all messages -- to make sure that
-    # subsequent messages will go through our proxy; that's
-    # particularly good if upstream and downstream entities
-    # use different transport protocol
-    if (method!="INVITE") {
-        record_route();
-    }
-
-    # loose-route processing
-    if (loose_route()) {
-        if (method=="INVITE") {
-            log(2, "----ROUTE: Relay re-INVITE\n");
-            # send it out now; use stateful forwarding as it works reliably even for UDP2TCP
-            if (!t_relay()) {
-                sl_reply_error();
-            }
-            break;
-        } else if (method=="ACK") {
-            log(2, "----ROUTE: Relay ACK\n");
-            # send it out now; use stateful forwarding as it works reliably even for UDP2TCP
-            if (!t_relay()) {
-                sl_reply_error();
-            }
-            break;
-        }
-    } else {
-        if (method=="BYE") {
-            xlog("L_WARN", "----ROUTE: Processing BYE without route header - F=$fu T=$tu IP=$si ID=$ci\n");
-            if (t_lookup_request()) {
-                log(2, "----ROUTE: Duplicated BYE\n");
-            } else {
-                # NOTE - don't t_relay before reporting usage
-                if (!reportospusage()) {
-                    xlog("L_WARN", "----ROUTE: failed to report usage, from '%fu' to '%tu'\n");
-                }
-                sl_send_reply("400", "Bad Request - no route header in BYE message");
-            }
-            break;
-        }
-    }
-
-    if (method=="INVITE") {
-        log(2, "----ROUTE: Processing INVITE\n");
-
-        # Stop retransmission
-        sl_send_reply("100", "Trying");
-
-        if (t_lookup_request()) {
-            log(2, "----ROUTE: Duplicated INVITE\n");
-            break;
-        }
-
-        # Authentication
-        log(3, "OSP authorization validation logic\n");
-
-        # This function looks for OSP peering token in the message.  It will fail
-        # if the token is not present
-        if (checkospheader()) {
-            log(3, "With OSP token, validate it\n"); 
-
-            # The function validates OSP tokens.  It will fail
-            # if the token is not valid or has expired
-            if (validateospheader()) {
-                # Authorization is valid.  The proxy can now use its own database of
-                # registered users for routing information.
-                # The proxy could also issue another OSP peering authorization and
-                # routing request by calling route(1) function.
-                log(3, "OSP authorization valid\n");
-
-                # Remove the OSP peering token from the received message
-                # Otherwise it will be forwarded on to the next hop
-                remove_hf("P-OSP-Auth-Token");
-            } else {
-                log(3, "OSP authorization invalid\n");
-                sl_send_reply("401", "Unauthorized");
-                break;
-            };
-        } else {
-            log(3, "Without OSP token, apply different authentication strategy\n"); 
-            log(3, "Go ahead, everyone is welcomed\n");
-
-            # # Implement authentication strategy here or simply add the
-            # # statements below to block all invites without OSP peering tokens
-            # sl_send_reply("401", "Unauthorized");
-            # break;
-        }
-
-        log(2, "----ROUTE: Authentication passed\n");
-        
-        # Routing
-
-#        if (lookup("location")) {
-#            log(2, "----ROUTE: Registered user, forward the message\n");
-#            append_hf("P-hint: usrloc\r\n");
-#            record_route();
-#            t_relay();
-#        } else {
-#            log(2, "----ROUTE: Unregistered user, use OSP to get routing\n");
-#            route(2);
-#        }
-        log(2, "----ROUTE: Use OSP to get routing\n");
-        route(2);
-    } else if (method=="ACK") {
-        log(2, "----ROUTE: Processing ACK\n");
-
-        if (t_lookup_request()) {
-            log(2, "----ROUTE: Relay E2E ACK\n");
-            t_relay();
-        } else {
-            log(2, "----ROUTE: Not to relay ACK");
-        }
-    } else if (method=="BYE") {
-        log(2, "----ROUTE: Processing BYE\n");
-
-        if (t_lookup_request()) {
-            log(2, "----ROUTE: Duplicated BYE\n");
-            break;
-        }
-
-        # NOTE - don't t_relay before reporting usage
-        if (!reportospusage()) {
-            xlog("L_WARN", "----ROUTE: failed to report usage, from '%fu' to '%tu'\n");
-        }
-
-        t_relay();
-    } else if (method=="CANCEL") {
-        log(2, "----ROUTE: Processing CANCEL\n");
-
-        if (t_lookup_request()) {
-            t_relay();
-        } else {
-            xlog("L_WARN", "----ROUTE: CANCEL without matching transaction, from '$fu' to '$tu'\n");
-        }
-    } else if ((method=="OPTIONS") && (uri==myself)) {
-        log(2, "----ROUTE: Processing OPTIONS\n");
-        options_reply();
-    } else if (method=="PRACK") {
-        log(2, "----ROUTE: Processing PRACK\n");
-        t_relay();
-    } else if (method=="INFO") {
-        log(2, "----ROUTE: Processing INFO\n");
-        t_relay();
-    } else if (method=="UPDATE") {
-        log(2, "----ROUTE: Processing UPDATE\n");
-        t_relay();
-#    } else if (method=="REGISTER") {
-#        log(2, "----ROUTE: Processing REGISTER\n");
-#
-#        # Stop retransmission
-#        sl_send_reply("100", "Trying");
-#        
-#        if (uri==myself) {
-#            log(2, "----ROUTE: Registered\n");
-#            save("location");
-#        } else {
-#            log(2, "----ROUTE: Register from outside domain rejected\n");
-#            sl_send_reply("488", "Unknown Domain");
-#        }
-    } else {
-        xlog("L_WARN", "----ROUTE: Unsupported message, $rm from '%fu' to '%tu'\n");
-        sl_send_reply("500", "Unsupported Message");
-    }
-
-    log(3, "----ROUTE: Route OUT\n");
-}
-
-
-# OSP Authorization and Routing
-route[2] {
-    log(3, "OSP authorization and routing logic\n");
-
-    # Is request to a phone number?
-    # A phone number consists of digits (0 through 9)
-    # and can begin with +
-#    if (uri=~"sip:[+,0-9][0-9]*@") {
-        # Requesting OSP peering routing and authorization
-        # The request may fail if:
-        #  o OSP peering servers are not available
-        #  o Authentication failed
-        #  o There is no route to destination or the route is blocked
-        log(3, "Requesting OSP authorization and routing\n");
-
-        requestosprouting();
-        if ($retcode == 1) {
-            log(3, "Response received\n");
-
-            setavpflag("fr._osp_orig_cookie_", dialog_cookie);
-            setavpflag("fr._osp_term_cookie_", dialog_cookie);
-            record_route();
-            
-            # Now we have 3 options.
-            #  o route(3) - sends a redirect to all available routes
-            #  o route(4) - fork off to all available routes
-            #  o route(5) in conjunction with failure_route(1) - sequentially tries all routes
-
-            # route(3);
-            # route(4);
-            route(5);
-        } else if ($retcode == -403) {
-            xlog("L_WARN", "----ROUTE: Call to '%tu' from source device '%si' is blocked on OSP Server.\n");
-            sl_send_reply("403", "Forbidden - Call is blocked");
-        } else if ($retcode == -404) {
-            xlog("L_WARN", "----ROUTE: No route on OSP server for call to '%tu' from source device '%si'.\n");
-            sl_send_reply("404", "Route Not Found");
-        } else if ($retcode == -500) {
-            log(3, "----ROUTE: Internal Server Error\n");
-            sl_send_reply("500", "Internal Server Error");
-        } else {
-            log(3, "----ROUTE: OSP Authorization failed\n");
-            sl_send_reply("503", "Service Not Available");
-        }
-#    } else {
-#        log(3, "Wrong phone number\n");
-#        sl_send_reply("401", "Not Phone Number");
-#    }
-}
-
-
-route[3] {
-    log(3, "Prepare all routes and redirect\n");
-
-    if (prepareallosproutes()) {
-        sl_send_reply("300", "Redirect");
-    } else {
-        log(3, "Failed to prepare all routes\n");
-        sl_send_reply("500", "Internal Server Error");
-    }
-}
-
-
-route[4] {
-    log(3, "Prepare all routes and fork-off\n");
-
-    if (prepareallosproutes()) {
-        t_relay();
-    } else {
-        log(3, "Failed to prepare all routes\n");
-        sl_send_reply("500", "Internal Server Error");
-    }
-}
-
-
-route[5] {
-    log(3, "Try the 1st route\n");
-
-    if (prepareospfirstroute()) {
-        t_on_branch("1");
-
-        t_on_failure("1");
-
-        t_relay();
-    } else {
-        log(3, "Could  not use the 1st route\n");
-        sl_send_reply("500", "Internal Server Error");
-    }
-}
-
-
-failure_route[1] {
-    if (t_check_status("487")) {
-        log(3, "Call canceled (status 487)\n");
-        break;
-    }
-
-    if (t_check_status("486")) {
-        log(3, "User busy (status 486)\n");
-        break;
-    }
-
-    # tm's t_local_replied has not been implemented in SER yet.
-    # if (t_check_status("408")) {
-    #     if (!t_local_replied("last")) {
-    #         log(3, "User unavailable (status 408)\n");
-    #         break;
-    #     }
-    # }
-
-    log(3, "Try the next route\n");
-
-    if (prepareospnextroute()) {
-        t_on_branch("1");
-
-        t_on_failure("1");
-
-        t_relay();
-    } else {
-        xlog("L_WARN", "----ROUTE: All destinations attempted for call ID '%ci'. Call cannot be completed.\n");
-        t_reply("503", "Service Not Available - Call cannot be completed");
-    }
-}
-
-
-branch_route[1] {
-    log(3, "Prepare route specific OSP information\n");
-    appendospheaders();
-}

+ 0 - 69
modules_s/osp/globals.c

@@ -1,69 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <stdio.h>
-#include <osp/osp.h>
-#include "osp_mod.h"
-
-unsigned int _osp_sp_number;
-char* _osp_sp_uris[OSP_DEF_SPS];
-unsigned long _osp_sp_weights[OSP_DEF_SPS] = {
-    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
-    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
-    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT,
-    OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT, OSP_DEF_WEIGHT
-};
-char* _osp_device_ip = NULL;
-char* _osp_device_port = NULL;
-unsigned char* _osp_private_key = NULL;
-unsigned char* _osp_local_certificate = NULL;
-unsigned char* _osp_ca_certificate = NULL;
-int _osp_crypto_hw = OSP_DEF_HW;
-int _osp_validate_callid = OSP_DEF_CALLID;
-int _osp_token_format = OSP_DEF_TOKEN;
-int _osp_ssl_lifetime = OSP_DEF_SSLLIFE;
-int _osp_persistence = OSP_DEF_PERSISTENCE;
-int _osp_retry_delay = OSP_DEF_DELAY;
-int _osp_retry_limit = OSP_DEF_RETRY;
-int _osp_timeout = OSP_DEF_TIMEOUT;
-int _osp_max_dests = OSP_DEF_DESTS;
-int _osp_use_rpid = OSP_DEF_USERPID;
-int _osp_redir_uri = OSP_DEF_REDIRURI;
-char _osp_PRIVATE_KEY[OSP_KEYBUF_SIZE];
-char _osp_LOCAL_CERTIFICATE[OSP_KEYBUF_SIZE];
-char _osp_CA_CERTIFICATE[OSP_KEYBUF_SIZE];
-
-OSPTPROVHANDLE _osp_provider = -1;
-

+ 0 - 545
modules_s/osp/orig_transaction.c

@@ -1,545 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <string.h>
-#include <osp/osp.h>
-#include "../../dset.h"
-#include "../../usr_avp.h"
-#include "../../mem/mem.h"
-#include "../auth/api.h"
-#include "orig_transaction.h"
-#include "destination.h"
-#include "osptoolkit.h"
-#include "sipheader.h"
-#include "usage.h"
-
-extern char* _osp_device_ip;
-extern char* _osp_device_port;
-extern int _osp_max_dests;
-extern OSPTPROVHANDLE _osp_provider;
-extern auth_api_t osp_auth;
-extern int _osp_redir_uri;
-
-const int OSP_FIRST_ROUTE = 1;
-const int OSP_NEXT_ROUTE = 0;
-const int OSP_MAIN_ROUTE = 1;
-const int OSP_BRANCH_ROUTE = 0;
-const str OSP_CALLING_NAME = {"_osp_calling_translated_", 24};
-
-static int ospLoadRoutes(OSPTTRANHANDLE transaction, int destcount, char* source, char* sourcedev, char* origcalled, time_t authtime);
-static int ospPrepareDestination(struct sip_msg* msg, int isfirst, int type, int format);
-
-/*
- * Get routes from AuthRsp
- * param transaction Transaction handle
- * param destcount Expected destination count
- * param source Source IP
- * param sourcedev Source device IP
- * param origcalled Original called number
- * param authtime Request authorization time
- * return 0 success, -1 failure
- */
-static int ospLoadRoutes(
-    OSPTTRANHANDLE transaction, 
-    int destcount, 
-    char* source, 
-    char* sourcedev, 
-    char* origcalled, 
-    time_t authtime)
-{
-    int count;
-    int errorcode;
-    osp_dest* dest;
-    osp_dest dests[OSP_DEF_DESTS];
-    OSPE_DEST_PROT protocol;
-    OSPE_DEST_OSP_ENABLED enabled;
-    int result = 0;
-    
-    LOG(L_DBG, "osp: ospLoadRoutes\n");
-
-    for (count = 0; count < destcount; count++) {
-        /* This is necessary becuase we will save destinations in reverse order */
-        dest = ospInitDestination(&dests[count]);
-
-        if (dest == NULL) {
-            result = -1;
-            break;
-        }
-
-        dest->destinationCount = count + 1;
-        strncpy(dest->origcalled, origcalled, sizeof(dest->origcalled) - 1);
-
-        if (count == 0) {
-            errorcode = OSPPTransactionGetFirstDestination(
-                transaction,
-                sizeof(dest->validafter),
-                dest->validafter,
-                dest->validuntil,
-                &dest->timelimit,
-                &dest->callidsize,
-                (void*)dest->callid,
-                sizeof(dest->called),
-                dest->called,
-                sizeof(dest->calling),
-                dest->calling,
-                sizeof(dest->host),
-                dest->host,
-                sizeof(dest->destdev),
-                dest->destdev,
-                &dest->tokensize,
-                dest->token);
-        } else {
-            errorcode = OSPPTransactionGetNextDestination(
-                transaction,
-                0,
-                sizeof(dest->validafter),
-                dest->validafter,
-                dest->validuntil,
-                &dest->timelimit,
-                &dest->callidsize,
-                (void*)dest->callid,
-                sizeof(dest->called),
-                dest->called,
-                sizeof(dest->calling),
-                dest->calling,
-                sizeof(dest->host),
-                dest->host,
-                sizeof(dest->destdev),
-                dest->destdev,
-                &dest->tokensize,
-                dest->token);
-        }
-        
-        if (errorcode != OSPC_ERR_NO_ERROR) {
-            LOG(L_ERR, 
-                "osp: ERROR: failed to load routes (%d) expected '%d' current '%d'\n", 
-                errorcode, 
-                destcount, 
-                count);
-            result = -1;
-            break;
-        }
-
-        errorcode = OSPPTransactionGetDestProtocol(transaction, &protocol);
-        if (errorcode != OSPC_ERR_NO_ERROR) {
-            /* This does not mean an ERROR. The OSP server may not support OSP 2.1.1 */
-            LOG(L_DBG, "osp: cannot get dest protocol (%d)\n", errorcode);
-            protocol = OSPE_DEST_PROT_SIP;
-        }
-        switch (protocol) {
-            case OSPE_DEST_PROT_H323_LRQ:
-            case OSPE_DEST_PROT_H323_SETUP:
-            case OSPE_DEST_PROT_IAX:
-                dest->supported = 0;
-                break;
-            case OSPE_DEST_PROT_SIP:
-            case OSPE_DEST_PROT_UNDEFINED:
-            case OSPE_DEST_PROT_UNKNOWN:
-            default:
-                dest->supported = 1;
-                break;
-        }
-
-        errorcode = OSPPTransactionIsDestOSPEnabled(transaction, &enabled);
-        if (errorcode != OSPC_ERR_NO_ERROR) {
-            /* This does not mean an ERROR. The OSP server may not support OSP 2.1.1 */
-            LOG(L_DBG, "osp: cannot get dest OSP version (%d)\n", errorcode);
-        } else if (enabled == OSPE_OSP_FALSE) {
-            /* Destination device does not support OSP. Do not send token to it */
-            dest->token[0] = '\0';
-            dest->tokensize = 0;
-        }
-
-        errorcode = OSPPTransactionGetDestNetworkId(transaction, dest->networkid);
-        if (errorcode != OSPC_ERR_NO_ERROR) {
-            /* This does not mean an ERROR. The OSP server may not support OSP 2.1.1 */
-            LOG(L_DBG, "osp: cannot get dest network ID (%d)\n", errorcode);
-            dest->networkid[0] = '\0';
-        }
-
-        strncpy(dest->source, source, sizeof(dest->source) - 1);
-        strncpy(dest->srcdev, sourcedev, sizeof(dest->srcdev) - 1);
-        dest->type = OSPC_SOURCE;
-        dest->transid = ospGetTransactionId(transaction);
-        dest->authtime = authtime;
-
-        LOG(L_INFO,
-            "osp: get destination '%d': "
-            "valid after '%s' "
-            "valid until '%s' "
-            "time limit '%i' seconds "
-            "call id '%.*s' "
-            "calling number '%s' "
-            "called number '%s' "
-            "host '%s' "
-            "supported '%d' "
-            "network id '%s' "
-            "token size '%i'\n",
-            count, 
-            dest->validafter, 
-            dest->validuntil, 
-            dest->timelimit, 
-            dest->callidsize, 
-            dest->callid, 
-            dest->calling, 
-            dest->called, 
-            dest->host, 
-            dest->supported,
-            dest->networkid, 
-            dest->tokensize);
-    }
-
-    /* 
-     * Save destination in reverse order,
-     * when we start searching avps the destinations
-     * will be in order 
-     */
-    if (result == 0) {
-        for(count = destcount -1; count >= 0; count--) {
-            ospSaveOrigDestination(&dests[count]);
-        }
-    }
-
-    return result;
-}
-
-/*
- * Request OSP authorization and routeing
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospRequestRouting(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    int errorcode;
-    time_t authtime;
-    char source[OSP_E164BUF_SIZE];
-    char sourcedev[OSP_STRBUF_SIZE];
-    char src[OSP_STRBUF_SIZE];
-    char destination[OSP_E164BUF_SIZE];
-    unsigned int callidnumber = 1;
-    OSPTCALLID* callids[callidnumber];
-    unsigned int logsize = 0;
-    char* detaillog = NULL;
-    const char** preferred = NULL;
-    unsigned int destcount;
-    OSPTTRANHANDLE transaction = -1;
-    int result = MODULE_RETURNCODE_FALSE;
-
-    LOG(L_DBG, "osp: ospRequestRouting\n");
-
-    authtime = time(NULL);
-
-    destcount = _osp_max_dests;
-
-    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction)) != OSPC_ERR_NO_ERROR) {
-        LOG(L_ERR, "osp: ERROR: failed to create new OSP transaction (%d)\n", errorcode);
-    } else if ((ospGetRpidUserpart(msg, source, sizeof(source)) != 0) &&
-        (ospGetFromUserpart(msg, source, sizeof(source)) != 0)) 
-    {
-        LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
-    } else if ((ospGetUriUserpart(msg, destination, sizeof(destination)) != 0) &&
-        (ospGetToUserpart(msg, destination, sizeof(destination)) != 0)) 
-    {
-        LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
-    } else if (ospGetCallId(msg, &(callids[0])) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
-    } else if (ospGetSourceAddress(msg, sourcedev, sizeof(sourcedev)) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
-    } else {
-        ospConvertAddress(sourcedev, src, sizeof(src));
-
-        LOG(L_INFO,
-            "osp: request auth and routing for: "
-            "source '%s' "
-            "source_port '%s' "
-            "source_dev '%s' "
-            "e164_source '%s' "
-            "e164_dest '%s' "
-            "call_id '%.*s' "
-            "dest_count '%i'\n",
-            _osp_device_ip,
-            _osp_device_port,
-            src,                        /* sourcedev in "[x.x.x.x]" or host.domain format */
-            source,
-            destination,
-            callids[0]->ospmCallIdLen,
-            callids[0]->ospmCallIdVal,
-            destcount
-        );    
-
-        /* try to request authorization */
-        errorcode = OSPPTransactionRequestAuthorisation(
-            transaction,       /* transaction handle */
-            _osp_device_ip,    /* from the configuration file */
-            src,               /* source of call, protocol specific, in OSP format */
-            source,            /* calling number in nodotted e164 notation */
-            OSPC_E164,         /* calling number format */
-            destination,       /* called number */
-            OSPC_E164,         /* called number format */
-            "",                /* optional username string, used if no number */
-            callidnumber,      /* number of call ids, here always 1 */
-            callids,           /* sized-1 array of call ids */
-            preferred,         /* preferred destinations, here always NULL */
-            &destcount,        /* max destinations, after call dest_count */
-            &logsize,          /* size allocated for detaillog (next param) 0=no log */
-            detaillog);        /* memory location for detaillog to be stored */
-
-        if ((errorcode == OSPC_ERR_NO_ERROR) &&
-            (ospLoadRoutes(transaction, destcount, _osp_device_ip, sourcedev, destination, authtime) == 0))
-        {
-            LOG(L_INFO,
-                "osp: there are '%d' OSP routes, call_id '%.*s'\n",
-                destcount,
-                callids[0]->ospmCallIdLen,
-                callids[0]->ospmCallIdVal);
-            result = MODULE_RETURNCODE_TRUE;
-        } else {
-            LOG(L_ERR,
-                "osp: ERROR: failed to request auth and routing (%i), call_id '%.*s\n",
-                errorcode,
-                callids[0]->ospmCallIdLen,
-                callids[0]->ospmCallIdVal);
-            switch (errorcode) {
-                case OSPC_ERR_TRAN_ROUTE_BLOCKED:
-                    result = -403;
-                    break;
-                case OSPC_ERR_TRAN_ROUTE_NOT_FOUND:
-                    result = -404;
-                    break;
-                case OSPC_ERR_NO_ERROR:
-                    /* AuthRsp ok but ospLoadRoutes fails */
-                    result = -500;
-                    break;
-                default:
-                    result = MODULE_RETURNCODE_FALSE;
-                    break;
-            }
-        }
-    }
-
-    if (callids[0] != NULL) {
-        OSPPCallIdDelete(&(callids[0]));
-    }
-
-    if (transaction != -1) {
-        OSPPTransactionDelete(transaction);
-    }
-    
-    return result;
-}
-
-/*
- * Check if there is a route
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospCheckRoute(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    LOG(L_DBG, "osp: ospCheckRoute\n");
-
-    if (ospCheckOrigDestination() == 0) {
-        return MODULE_RETURNCODE_TRUE;
-    } else {
-        return MODULE_RETURNCODE_FALSE;
-    }
-}
-
-/*
- * Append route specific OSP headers
- *     This function only works in branch route block. 
- *     This function is only for SER. SER does not support rewrite_uri in BRANCH_ROUTE.
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failed
- */
-int ospAppendHeaders(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    osp_dest* dest;
-    int result = MODULE_RETURNCODE_FALSE;
-
-    LOG(L_DBG, "osp: ospAppendHeaders\n");
-
-    dest = ospGetLastOrigDestination();
-    if (dest != NULL) {
-        ospAddOspHeader(msg, dest->token, dest->tokensize);
-        result = MODULE_RETURNCODE_TRUE;
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to get last used destination\n");
-    }
-
-    return result;
-}
-
-/*
- * Build SIP message for destination
- * param msg SIP message
- * param isfirst Is first destination
- * param type Main or branch route block
- * param format URI format
- * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure
- */
-static int ospPrepareDestination(
-    struct sip_msg* msg, 
-    int isfirst,
-    int type,
-    int format)
-{
-    str newuri = {NULL, 0};
-    int result = MODULE_RETURNCODE_FALSE;
-
-    LOG(L_DBG, "osp: ospPrepareDestination\n");
-
-    osp_dest *dest = ospGetNextOrigDestination();
-
-    if (dest != NULL) {
-        ospRebuildDestionationUri(&newuri, dest->called, dest->host, "", format);
-
-        LOG(L_INFO, 
-            "osp: prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%llu'\n",
-            newuri.len,
-            newuri.s,
-            dest->callidsize,
-            dest->callid,
-            dest->transid);
-
-        if (type == OSP_MAIN_ROUTE) {
-            if (isfirst == OSP_FIRST_ROUTE) {
-                rewrite_uri(msg, &newuri);
-            } else {
-                append_branch(msg, newuri.s, newuri.len, NULL, 0, Q_UNSPECIFIED, NULL);
-            }
-
-            result = MODULE_RETURNCODE_TRUE;
-        } else {
-            LOG(L_ERR, "osp: ERROR: unsupported route block type\n");
-        }
-    } else {
-        LOG(L_DBG, "osp: there is no more routes\n");
-        ospReportOrigSetupUsage();
-    }
-
-    if (newuri.len > 0) {
-        pkg_free(newuri.s);
-    }
-    
-    return result;
-}
-
-/*
- * Prepare OSP first route
- *     This function prepare the first OSP route
- *     This function is only for SER. SER does not support rewrite_uri in BRANCH_ROUTE.
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospPrepareFirstRoute(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    int result = MODULE_RETURNCODE_TRUE;
-
-    LOG(L_DBG, "osp: ospPrepareFirstRoute\n");
-
-    result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_MAIN_ROUTE, 0);
-
-    return result;
-}
-
-/*
- * Prepare OSP next route
- *     This function prepare the next OSP route
- *     This function is only for SER. SER does not support rewrite_uri in BRANCH_ROUTE.
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospPrepareNextRoute(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    int result = MODULE_RETURNCODE_TRUE;
-
-    LOG(L_DBG, "osp: ospPrepareNextRoute\n");
-
-    result = ospPrepareDestination(msg, OSP_NEXT_ROUTE, OSP_MAIN_ROUTE, 0);
-
-    return result;
-}
-
-/*
- * Prepare all OSP routes
- *     This function does not work in branch route block.
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospPrepareAllRoutes(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    int result = MODULE_RETURNCODE_TRUE;
-
-    LOG(L_DBG, "osp: ospPrepareAllRoutes\n");
-
-    for(result = ospPrepareDestination(msg, OSP_FIRST_ROUTE, OSP_MAIN_ROUTE, _osp_redir_uri);
-        result == MODULE_RETURNCODE_TRUE;
-        result = ospPrepareDestination(msg, OSP_NEXT_ROUTE, OSP_MAIN_ROUTE, _osp_redir_uri))
-    {
-    }
-
-    return MODULE_RETURNCODE_TRUE;
-}
-

+ 0 - 49
modules_s/osp/orig_transaction.h

@@ -1,49 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_ORIG_TRANSACTION_H_
-#define _OSP_MOD_ORIG_TRANSACTION_H_
-
-#include "../../parser/msg_parser.h"
-
-int ospRequestRouting(struct sip_msg*, char*, char*);
-int ospCheckRoute(struct sip_msg*, char*, char*);
-int ospPrepareFirstRoute(struct sip_msg*, char*, char*);
-int ospPrepareNextRoute(struct sip_msg*, char*, char*);
-int ospPrepareAllRoutes(struct sip_msg*, char*, char*);
-int ospAppendHeaders(struct sip_msg*, char*, char*);
-
-#endif /* _OSP_MOD_ORIG_TRANSACTION_H_ */
-

+ 0 - 307
modules_s/osp/osp_mod.c

@@ -1,307 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <osp/osp.h>
-#include "../../sr_module.h"
-#include "osp_mod.h"
-#include "orig_transaction.h"
-#include "term_transaction.h"
-#include "usage.h"
-#include "tm.h"
-#include "provider.h"
-
-MODULE_VERSION
-
-extern unsigned int _osp_sp_number;
-extern char* _osp_sp_uris[];
-extern unsigned long _osp_sp_weights[];
-extern char* _osp_device_ip;
-extern char* _osp_device_port;
-extern unsigned char* _osp_private_key;
-extern unsigned char* _osp_local_certificate;
-extern unsigned char* _osp_ca_certificate;
-extern int _osp_crypto_hw;
-extern int _osp_validate_callid;
-extern int _osp_token_format;
-extern int _osp_ssl_lifetime;
-extern int _osp_persistence;
-extern int _osp_retry_delay;
-extern int _osp_retry_limit;
-extern int _osp_timeout;
-extern int _osp_max_dests;
-extern int _osp_use_rpid;
-extern int _osp_redir_uri;
-extern char _osp_PRIVATE_KEY[];
-extern char _osp_LOCAL_CERTIFICATE[];
-extern char _osp_CA_CERTIFICATE[];
-extern OSPTPROVHANDLE _osp_provider;
-
-int osp_index[OSP_DEF_SPS];
-
-static int ospInitMod(void);
-static void ospDestMod(void);
-static int ospInitChild(int);
-static int  ospVerifyParameters(void);
-static void ospDumpParameters(void);
-
-static cmd_export_t cmds[]={
-    {"checkospheader",          ospCheckHeader,      0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"validateospheader",       ospValidateHeader,   0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"requestosprouting",       ospRequestRouting,   0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"checkosproute",           ospCheckRoute,       0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"prepareospfirstroute",    ospPrepareFirstRoute,0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"prepareospnextroute",     ospPrepareNextRoute, 0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"prepareallosproutes",     ospPrepareAllRoutes, 0, 0, REQUEST_ROUTE|FAILURE_ROUTE}, 
-    {"appendospheaders",        ospAppendHeaders,    0, 0, BRANCH_ROUTE}, 
-    {"reportospusage",          ospReportUsage,      0, 0, REQUEST_ROUTE}, 
-    {0, 0, 0, 0, 0}
-};
-
-static param_export_t params[]={
-    {"sp1_uri",                        STR_PARAM, &_osp_sp_uris[0]},
-    {"sp2_uri",                        STR_PARAM, &_osp_sp_uris[1]},
-    {"sp3_uri",                        STR_PARAM, &_osp_sp_uris[2]},
-    {"sp4_uri",                        STR_PARAM, &_osp_sp_uris[3]},
-    {"sp5_uri",                        STR_PARAM, &_osp_sp_uris[4]},
-    {"sp6_uri",                        STR_PARAM, &_osp_sp_uris[5]},
-    {"sp7_uri",                        STR_PARAM, &_osp_sp_uris[6]},
-    {"sp8_uri",                        STR_PARAM, &_osp_sp_uris[7]},
-    {"sp9_uri",                        STR_PARAM, &_osp_sp_uris[8]},
-    {"sp10_uri",                       STR_PARAM, &_osp_sp_uris[9]},
-    {"sp11_uri",                       STR_PARAM, &_osp_sp_uris[10]},
-    {"sp12_uri",                       STR_PARAM, &_osp_sp_uris[11]},
-    {"sp13_uri",                       STR_PARAM, &_osp_sp_uris[12]},
-    {"sp14_uri",                       STR_PARAM, &_osp_sp_uris[13]},
-    {"sp15_uri",                       STR_PARAM, &_osp_sp_uris[14]},
-    {"sp16_uri",                       STR_PARAM, &_osp_sp_uris[15]},
-    {"sp1_weight",                     INT_PARAM, &(_osp_sp_weights[0])},
-    {"sp2_weight",                     INT_PARAM, &(_osp_sp_weights[1])},
-    {"sp3_weight",                     INT_PARAM, &(_osp_sp_weights[2])},
-    {"sp4_weight",                     INT_PARAM, &(_osp_sp_weights[3])},
-    {"sp5_weight",                     INT_PARAM, &(_osp_sp_weights[4])},
-    {"sp6_weight",                     INT_PARAM, &(_osp_sp_weights[5])},
-    {"sp7_weight",                     INT_PARAM, &(_osp_sp_weights[6])},
-    {"sp8_weight",                     INT_PARAM, &(_osp_sp_weights[7])},
-    {"sp9_weight",                     INT_PARAM, &(_osp_sp_weights[8])},
-    {"sp10_weight",                    INT_PARAM, &(_osp_sp_weights[9])},
-    {"sp11_weight",                    INT_PARAM, &(_osp_sp_weights[10])},
-    {"sp12_weight",                    INT_PARAM, &(_osp_sp_weights[11])},
-    {"sp13_weight",                    INT_PARAM, &(_osp_sp_weights[12])},
-    {"sp14_weight",                    INT_PARAM, &(_osp_sp_weights[13])},
-    {"sp15_weight",                    INT_PARAM, &(_osp_sp_weights[14])},
-    {"sp16_weight",                    INT_PARAM, &(_osp_sp_weights[15])},
-    {"device_ip",                      STR_PARAM, &_osp_device_ip},
-    {"device_port",                    STR_PARAM, &_osp_device_port},
-    {"private_key",                    STR_PARAM, &_osp_private_key},
-    {"local_certificate",              STR_PARAM, &_osp_local_certificate},
-    {"ca_certificates",                STR_PARAM, &_osp_ca_certificate},
-    {"enable_crypto_hardware_support", INT_PARAM, &_osp_crypto_hw},
-    {"validate_callid",                INT_PARAM, &(_osp_validate_callid)},
-    {"token_format",                   INT_PARAM, &_osp_token_format},
-    {"ssl_lifetime",                   INT_PARAM, &_osp_ssl_lifetime},
-    {"persistence",                    INT_PARAM, &_osp_persistence},
-    {"retry_delay",                    INT_PARAM, &_osp_retry_delay},
-    {"retry_limit",                    INT_PARAM, &_osp_retry_limit},
-    {"timeout",                        INT_PARAM, &_osp_timeout},
-    {"max_destinations",               INT_PARAM, &_osp_max_dests},
-    {"use_rpid_for_calling_number",    INT_PARAM, &_osp_use_rpid},
-    {"redirection_uri_format",         INT_PARAM, &_osp_redir_uri},
-    {0,0,0} 
-};
-
-struct module_exports exports = {
-    "osp",
-    cmds,
-    0,            /* RPC methods */
-    params,
-    ospInitMod,   /* module initialization function */
-    0,            /* response function*/
-    ospDestMod,   /* destroy function */
-    0,            /* oncancel function */
-    ospInitChild, /* per-child init function */
-};
-
-/*
- * Initialize OSP module
- * return 0 success, -1 failure
- */
-static int ospInitMod(void)
-{
-    LOG(L_DBG, "osp: ospInitMod\n");
-
-    if (ospVerifyParameters() != 0) {
-        /* At least one parameter incorrect -> error */
-        return -1;   
-    }
-
-    if (ospInitTm() < 0) {
-        return -1;
-    }
-
-    /* everything is fine, initialization done */
-    return 0;
-}
-
-/*
- * Destrroy OSP module
- */
-static void ospDestMod(void)
-{
-    LOG(L_DBG, "osp: ospDestMod\n");
-}
-
-/*
- * Initializeild process of OSP module
- * param rank
- * return 0 success, -1 failure
- */
-static int ospInitChild(
-    int rank)
-{
-    int code = -1;
-
-    LOG(L_DBG, "osp: ospInitChild\n");
-
-    code = ospSetupProvider();
-
-    LOG(L_DBG, "osp: provider '%i' (%d)\n", _osp_provider, code);
-
-    return 0;
-}
-
-/*
- * Verify parameters for OSP module
- * return 0 success, -1 failure
- */
-static int ospVerifyParameters(void)
-{
-    int i;
-    int result = 0;
-
-    LOG(L_DBG, "osp: ospVerifyParamters\n");
-
-    /* Default location for the cert files is in the compile time variable CFG_DIR */
-    if (_osp_private_key == NULL) {
-        sprintf(_osp_PRIVATE_KEY, "%spkey.pem", CFG_DIR);
-        _osp_private_key = (unsigned char*)_osp_PRIVATE_KEY;
-    } 
-
-    if (_osp_local_certificate == NULL) {
-        sprintf(_osp_LOCAL_CERTIFICATE, "%slocalcert.pem", CFG_DIR);
-        _osp_local_certificate = (unsigned char*)_osp_LOCAL_CERTIFICATE;
-    }
-
-    if (_osp_ca_certificate == NULL) {
-        sprintf(_osp_CA_CERTIFICATE, "%scacert_0.pem", CFG_DIR);
-        _osp_ca_certificate = (unsigned char*)_osp_CA_CERTIFICATE;
-    }
-
-    if (_osp_device_ip == NULL) {
-        _osp_device_ip = "";
-    }
-
-    if (_osp_device_port == NULL) {
-        _osp_device_port = "";
-    }
-
-    if (_osp_max_dests > OSP_DEF_DESTS || _osp_max_dests < 1) {
-        _osp_max_dests = OSP_DEF_DESTS;    
-        LOG(L_WARN,
-            "osp: WARN: max_destinations is out of range, reset to %d\n", 
-            OSP_DEF_DESTS);
-    }
-
-    if (_osp_token_format < 0 || _osp_token_format > 2) {
-        _osp_token_format = OSP_DEF_TOKEN;
-        LOG(L_WARN, 
-            "osp: WARN: token_format is out of range, reset to %d\n", 
-            OSP_DEF_TOKEN);
-    }
-
-    _osp_sp_number = 0;
-    for (i = 0; i < OSP_DEF_SPS; i++) {
-        if (_osp_sp_uris[i] != NULL) {
-            if (_osp_sp_number != i) {
-                _osp_sp_uris[_osp_sp_number] = _osp_sp_uris[i];
-                _osp_sp_weights[_osp_sp_number] = _osp_sp_weights[i];
-                _osp_sp_uris[i] = NULL;
-                _osp_sp_weights[i] = OSP_DEF_WEIGHT;
-            }
-            osp_index[_osp_sp_number] = i + 1;
-            _osp_sp_number++;
-        }
-    }
-
-    if (_osp_sp_number == 0) {
-        LOG(L_ERR, "osp: ERROR: at least one service point uri must be configured\n");
-        result = -1;
-    }
-
-    ospDumpParameters();
-
-    return result;
-}
-
-/*
- * Dump OSP module configuration
- */
-static void ospDumpParameters(void) 
-{
-    int i;
-
-    LOG(L_INFO, "osp: module configuration: ");
-    LOG(L_INFO, "    number of service points '%d'", _osp_sp_number);
-    for (i = 0; i < _osp_sp_number; i++) {
-        LOG(L_INFO,
-            "    sp%d_uri '%s' sp%d_weight '%ld' ", 
-            osp_index[i], _osp_sp_uris[i], osp_index[i], _osp_sp_weights[i]);
-    }
-    LOG(L_INFO, "    device_ip '%s' device_port '%s' ", _osp_device_ip, _osp_device_port);
-    LOG(L_INFO, "    private_key '%s' ", _osp_private_key);
-    LOG(L_INFO, "    local_certificate '%s' ", _osp_local_certificate);
-    LOG(L_INFO, "    ca_certificates '%s' ", _osp_ca_certificate);
-    LOG(L_INFO, "    enable_crypto_hardware_support '%d' ", _osp_crypto_hw);
-    LOG(L_INFO, "    token_format '%d' ", _osp_token_format);
-    LOG(L_INFO, "    ssl_lifetime '%d' ", _osp_ssl_lifetime);
-    LOG(L_INFO, "    persistence '%d' ", _osp_persistence);
-    LOG(L_INFO, "    retry_delay '%d' ", _osp_retry_delay);
-    LOG(L_INFO, "    retry_limit '%d' ", _osp_retry_limit);
-    LOG(L_INFO, "    timeout '%d' ", _osp_timeout);
-    LOG(L_INFO, "    validate_call_id '%d' ", _osp_validate_callid);
-    LOG(L_INFO, "    use_rpid_for_calling_number '%d' ", _osp_use_rpid);
-    LOG(L_INFO, "    redirection_uri_format '%d' ", _osp_redir_uri);
-    LOG(L_INFO, "    max_destinations '%d'\n", _osp_max_dests);
-}
-

+ 0 - 64
modules_s/osp/osp_mod.h

@@ -1,64 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_H_
-#define _OSP_MOD_H_
-
-#define MODULE_RETURNCODE_TRUE          1
-#define MODULE_RETURNCODE_STOPROUTE     0
-#define MODULE_RETURNCODE_FALSE         -1
-
-#define OSP_DEF_SPS                     16
-#define OSP_DEF_WEIGHT                  1000
-#define OSP_DEF_HW                      0
-#define OSP_DEF_CALLID                  1    /* Validate call ids, set to 0 to disable */
-#define OSP_DEF_TOKEN                   2
-#define OSP_DEF_SSLLIFE                 300
-#define OSP_DEF_PERSISTENCE             (60 * 1000)
-#define OSP_DEF_DELAY                   0
-#define OSP_DEF_RETRY                   2
-#define OSP_DEF_TIMEOUT                 (60 * 1000)
-#define OSP_DEF_DESTS                   5
-#define OSP_DEF_USERPID                 1
-#define OSP_DEF_REDIRURI                0   /* 0 for "[email protected]", 1 for "<[email protected]>" format */
-
-#define OSP_KEYBUF_SIZE                 256
-#define OSP_STRBUF_SIZE                 256
-#define OSP_E164BUF_SIZE                1024
-#define OSP_TOKENBUF_SIZE               2048
-#define OSP_HEADERBUF_SIZE              3072
-
-#endif /* _OSP_MOD_H_ */
-

+ 0 - 193
modules_s/osp/osptoolkit.c

@@ -1,193 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <osp/osptrans.h>
-#include "../../dprint.h"
-#include "osptoolkit.h"
-
-static OSPTTHREADRETURN ospReportUsageWork(void* usagearg);
-
-typedef struct _osp_usage
-{
-    OSPTTRANHANDLE ospvTransaction;     /* Transaction handle */
-    unsigned ospvReleaseCode;           /* Release code */
-    unsigned ospvDuration;              /* Length of call */
-    time_t ospvStartTime;               /* Call start time */
-    time_t ospvEndTime;                 /* Call end time */
-    time_t ospvAlertTime;               /* Call alert time */
-    time_t ospvConnectTime;             /* Call connect time */
-    unsigned ospvIsPDDInfoPresent;      /* Is PDD Info present */
-    unsigned ospvPostDialDelay;         /* Post Dial Delay */
-    unsigned ospvReleaseSource;         /* EP that released the call */
-} osp_usage;
-
-/*
- * Get OSP transaction ID from transaction handle
- * param transaction OSP transaction headle
- * return OSP transaction ID
- */
-unsigned long long ospGetTransactionId(
-    OSPTTRANHANDLE transaction)
-{
-    OSPTTRANS* context = NULL;
-    unsigned long long id = 0;
-    int errorcode = OSPC_ERR_NO_ERROR;
-
-    LOG(L_DBG, "osp: ospGetTransactionId\n");
-
-    context = OSPPTransactionGetContext(transaction, &errorcode);
-
-    if (errorcode == OSPC_ERR_NO_ERROR) {
-        id = (unsigned long long)context->TransactionID;
-    } else {
-        LOG(L_ERR, 
-            "osp: ERROR: failed to extract transaction_id from transaction handle %d (%d)\n",
-            transaction,
-            errorcode);
-    }
-
-    return id;
-}
-
-/*
- * Create a thread to report OSP usage
- * param ospvTransaction OSP transaction handle
- * param ospvReleaseCode Call release reason
- * param ospvDurating Call duration
- * param ospvStartTime Call start time
- * param ospvEndTime Call end time
- * param ospvAlertTime Call alert time
- * param ospvConnectTime Call connected  time
- * param ospvIsPDDInfoPresent If post dial delay information avaliable
- * param ospvPostDialDelay Post dial delay information
- * param ospvReleaseSource Which side release the call
- */
-void ospReportUsageWrapper(
-    OSPTTRANHANDLE ospvTransaction,
-    unsigned ospvReleaseCode,
-    unsigned ospvDuration,
-    time_t ospvStartTime,
-    time_t ospvEndTime,
-    time_t ospvAlertTime,
-    time_t ospvConnectTime,
-    unsigned ospvIsPDDInfoPresent,
-    unsigned ospvPostDialDelay,
-    unsigned ospvReleaseSource)
-{
-    osp_usage* usage;
-    OSPTTHREADID threadid;
-    OSPTTHRATTR threadattr;
-    int errorcode;
-
-    LOG(L_DBG, "osp: ospReportUsageWrapper\n");
-    LOG(L_DBG, "osp: schedule usage report for '%llu'\n", ospGetTransactionId(ospvTransaction));
-
-    usage = (osp_usage*)malloc(sizeof(osp_usage));
-
-    usage->ospvTransaction = ospvTransaction;
-    usage->ospvReleaseCode = ospvReleaseCode;
-    usage->ospvDuration = ospvDuration;
-    usage->ospvStartTime = ospvStartTime;
-    usage->ospvEndTime = ospvEndTime;
-    usage->ospvAlertTime = ospvAlertTime;
-    usage->ospvConnectTime = ospvConnectTime;
-    usage->ospvIsPDDInfoPresent = ospvIsPDDInfoPresent;
-    usage->ospvPostDialDelay = ospvPostDialDelay;
-    usage->ospvReleaseSource = ospvReleaseSource;
-
-    OSPM_THRATTR_INIT(threadattr, errorcode);
-
-    OSPM_SETDETACHED_STATE(threadattr, errorcode);
-
-    OSPM_CREATE_THREAD(threadid, &threadattr, ospReportUsageWork, usage, errorcode);
-
-    OSPM_THRATTR_DESTROY(threadattr);
-}
-
-/*
- * Report OSP usage thread function
- * param usagearg OSP usage information
- * return
- */
-static OSPTTHREADRETURN ospReportUsageWork(
-    void* usagearg)
-{
-    int i;
-    const int MAX_RETRIES = 5;
-    osp_usage* usage;
-    int errorcode;
-
-    LOG(L_DBG, "osp: ospReportUsageWork\n");
-
-    usage = (osp_usage*)usagearg;
-
-    OSPPTransactionRecordFailure(
-        usage->ospvTransaction,
-        (enum OSPEFAILREASON)usage->ospvReleaseCode);
-
-    for (i = 1; i <= MAX_RETRIES; i++) {
-        errorcode = OSPPTransactionReportUsage(
-            usage->ospvTransaction,
-            usage->ospvDuration,
-            usage->ospvStartTime,
-            usage->ospvEndTime,
-            usage->ospvAlertTime,
-            usage->ospvConnectTime,
-            usage->ospvIsPDDInfoPresent,
-            usage->ospvPostDialDelay,
-            usage->ospvReleaseSource,
-            (unsigned char*)"", 0, 0, 0, 0, NULL, NULL);
-
-        if (errorcode == OSPC_ERR_NO_ERROR) {
-            LOG(L_DBG, 
-                "osp: reporte usage for '%llu'\n", 
-                ospGetTransactionId(usage->ospvTransaction));
-            break;
-        } else {
-            LOG(L_ERR, 
-                "osp: ERROR: failed to report usage for '%llu' (%d) attempt '%d' of '%d'\n",
-                ospGetTransactionId(usage->ospvTransaction), 
-                errorcode,
-                i,
-                MAX_RETRIES);
-        }
-    }
-
-    OSPPTransactionDelete(usage->ospvTransaction);
-
-    free(usage);
-
-    OSPTTHREADRETURN_NULL();
-}

+ 0 - 65
modules_s/osp/osptoolkit.h

@@ -1,65 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_OSPTOOLKIT_H_
-#define _OSP_MOD_OSPTOOLKIT_H_
-
-#include <osp/osp.h>
-
-/* 
- * This module implements help functions for the OSP toolkit.
- * Some of the functions maybe impemented by the toolkit in the future.
- */
-
-/* 
- * Returns the OSP transaction id generated by the server.  The id is
- * returned in the Authorization Response and also packaged in the token.
- */
-unsigned long long ospGetTransactionId(OSPTTRANHANDLE transaction);
-void ospReportUsageWrapper(
-    OSPTTRANHANDLE ospvTransaction,     /* In - Transaction handle */
-    unsigned ospvReleaseCode,           /* In - Release code */
-    unsigned ospvDuration,              /* In - Length of call */
-    time_t ospvStartTime,               /* In - Call start time */
-    time_t ospvEndTime,                 /* In - Call end time */
-    time_t ospvAlertTime,               /* In - Call alert time */
-    time_t ospvConnectTime,             /* In - Call connect time */
-    unsigned ospvIsPDDInfoPresent,      /* In - Is PDD Info present */
-    unsigned ospvPostDialDelay,         /* In - Post Dial Delay */
-    unsigned ospvReleaseSource          /* In - EP that released the call */
-);
-
-#endif /* _OSP_MOD_OSPTOOLKIT_H_ */
-

+ 0 - 142
modules_s/osp/provider.c

@@ -1,142 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <osp/osp.h>
-#include <osp/osputils.h>
-#include "../../dprint.h"
-#include "provider.h"
-
-extern unsigned int _osp_sp_number;
-extern char* _osp_sp_uris[];
-extern unsigned long _osp_sp_weights[];
-extern unsigned char* _osp_private_key;
-extern unsigned char* _osp_local_certificate;
-extern unsigned char* _osp_ca_certificate;
-extern int _osp_ssl_lifetime;
-extern int _osp_persistence;
-extern int _osp_retry_delay;
-extern int _osp_retry_limit;
-extern int _osp_timeout;
-extern int _osp_crypto_hw;
-extern OSPTPROVHANDLE _osp_provider;
-
-/*
- * Create a new OSP provider object per process
- * return 0 success, others failure
- */
-int ospSetupProvider(void) 
-{
-    OSPTPRIVATEKEY privatekey;
-    OSPTCERT localcert;
-    OSPTCERT cacert;
-    OSPTCERT* cacerts[1];
-    int result;
-
-    LOG(L_DBG, "osp: ospSetupProvider\n");
-
-    cacerts[0] = &cacert;
-
-    if ((result = OSPPInit(_osp_crypto_hw)) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to initalize OSP (%i)\n", result);
-    } else if (OSPPUtilLoadPEMPrivateKey(_osp_private_key, &privatekey) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to load private key from '%s'\n", _osp_private_key);
-    } else if (OSPPUtilLoadPEMCert(_osp_local_certificate, &localcert) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to load local certificate from '%s'\n",_osp_local_certificate);
-    } else if (OSPPUtilLoadPEMCert(_osp_ca_certificate, &cacert) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to load CA certificate from '%s'\n", _osp_ca_certificate);
-    } else {
-        result = OSPPProviderNew(
-            _osp_sp_number,
-            (const char**)_osp_sp_uris,
-            _osp_sp_weights,
-            "http://localhost:1234",
-            &privatekey,
-            &localcert,
-            1,
-            (const OSPTCERT**)cacerts,
-            1,
-            _osp_ssl_lifetime,
-            _osp_sp_number,
-            _osp_persistence,
-            _osp_retry_delay,
-            _osp_retry_limit,
-            _osp_timeout,
-            "",
-            "",
-            &_osp_provider);
-        if (result != 0) {
-            LOG(L_ERR, "osp: ERROR: failed to create provider (%i)\n", result);
-        } else {
-            LOG(L_DBG, "osp: created new (per process) provider '%d'\n", _osp_provider);
-            result = 0;
-        }
-    }
-
-    /* 
-     * Free space allocated while loading crypto information from PEM-encoded files.
-     * There are some problems to free the memory, do not free them
-     */
-    if (privatekey.PrivateKeyData != NULL) {
-        //free(privatekey.PrivateKeyData);
-    }
-
-    if (localcert.CertData != NULL) {
-        //free(localcert.CertData);
-    }
-    
-    if (cacert.CertData != NULL) {
-        //free(localcert.CertData);
-    }
-
-    return result;
-}
-
-/*
- * Erase OSP provider object
- * return 0 success, others failure
- */
-int ospDeleteProvider(void) 
-{
-    int result;
-
-    LOG(L_DBG, "osp: ospDeleteProvider\n");
-
-    if ((result = OSPPProviderDelete(_osp_provider, 0)) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to erase provider '%d' (%d)\n", _osp_provider, result);
-    }
-    
-    return result;
-}
-

+ 0 - 43
modules_s/osp/provider.h

@@ -1,43 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_PROVIDER_H_
-#define _OSP_MOD_PROVIDER_H_
-
-int ospSetupProvider(void);
-int ospDeleteProvider(void);
-
-#endif /* _OSP_MOD_PROVIDER_H_ */
-

+ 0 - 725
modules_s/osp/sipheader.c

@@ -1,725 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <osp/osp.h>
-#include <osp/ospb64.h>
-#include "../../trim.h"
-#include "../../forward.h"
-#include "../../parser/parse_from.h"
-#include "../../parser/parse_rpid.h"
-#include "../../parser/parse_rr.h"
-#include "../../parser/parse_uri.h"
-#include "../../data_lump.h"
-#include "../../mem/mem.h"
-#include "osp_mod.h"
-#include "sipheader.h"
-
-extern int _osp_use_rpid;
-
-static void ospSkipPlus(char* e164);
-static int ospAppendHeader(struct sip_msg* msg, str* header); 
-
-/* 
- * Copy str to buffer and check overflow 
- * param source Str
- * param buffer Buffer
- * param buffersize Size of buffer
- */
-void ospCopyStrToBuffer(
-    str* source, 
-    char* buffer, 
-    int buffersize)
-{
-    int copybytes;
-
-    LOG(L_DBG, "osp: ospCopyStrToBuffer\n");
-
-    if (source->len > buffersize - 1) {
-        LOG(L_ERR,
-            "osp: ERROR: buffer for copying '%.*s' is too small, will copy the first '%d' bytes\n",
-            source->len,
-            source->s, 
-            buffersize);
-        copybytes = buffersize - 1;
-    } else {
-        copybytes = source->len;
-    }
-
-    strncpy(buffer, source->s, copybytes);
-    buffer[copybytes] = '\0';
-}
-
-/* 
- * Remove '+' in E164 string
- * param e164 E164 string
- */
-static void ospSkipPlus(
-    char* e164)
-{
-    LOG(L_DBG, "osp: ospSkipPlus\n");
-
-    if (*e164 == '+') {
-        strncpy(e164, e164 + 1, strlen(e164) - 1);
-        e164[strlen(e164) - 1] = '\0';
-    }
-}
-
-/* 
- * Get calling number from From header
- * param msg SIP message
- * param fromuser User part of From header
- * param buffersize Size of fromuser buffer
- * return 0 success, -1 failure
- */
-int ospGetFromUserpart(
-    struct sip_msg* msg, 
-    char* fromuser, 
-    int buffersize)
-{
-    struct to_body* from;
-    struct sip_uri uri;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetFromUserpart\n");
-
-    fromuser[0] = '\0';
-
-    if (msg->from != NULL) {
-        if (parse_from_header(msg) == 0) {
-            from = get_from(msg);
-            if (parse_uri(from->uri.s, from->uri.len, &uri) == 0) {
-                ospCopyStrToBuffer(&uri.user, fromuser, buffersize);
-                ospSkipPlus(fromuser);
-                result = 0;
-            } else {
-                LOG(L_ERR, "osp: ERROR: failed to parse From uri\n");
-            }
-        } else {
-            LOG(L_ERR, "osp: ERROR: failed to parse From header\n");
-        }
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to find From header\n");
-    }
-
-    return result;
-}
-
-/* 
- * Get calling number from Remote-Party-ID header
- * param msg SIP message
- * param rpiduser User part of Remote-Party-ID header
- * param buffersize Size of fromuser buffer
- * return 0 success, -1 failure
- */
-int ospGetRpidUserpart(
-    struct sip_msg* msg, 
-    char* rpiduser, 
-    int buffersize)
-{
-    struct to_body* rpid;
-    struct sip_uri uri;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetRpidUserpart\n");
-
-    rpiduser[0] = '\0';
-
-    if (_osp_use_rpid != 0) {
-        if (msg->rpid != NULL) {
-            if (parse_rpid_header(msg) == 0) {
-                rpid = get_rpid(msg);
-                if (parse_uri(rpid->uri.s, rpid->uri.len, &uri) == 0) {
-                    ospCopyStrToBuffer(&uri.user, rpiduser, buffersize);
-                    ospSkipPlus(rpiduser);
-                    result = 0;
-                } else {
-                    LOG(L_ERR, "osp: ERROR: failed to parse RPID uri\n");
-                }
-            } else {
-                LOG(L_ERR, "osp: ERROR: failed to parse RPID header\n");
-            }
-        } else {
-            LOG(L_DBG, "osp: without RPID header\n");
-        }
-    } else {
-        LOG(L_DBG, "osp: do not use RPID header\n");
-    }
-
-    return result;
-}
-
-/* 
- * Get called number from To header
- * param msg SIP message
- * param touser User part of To header
- * param buffersize Size of touser buffer
- * return 0 success, -1 failure
- */
-int ospGetToUserpart(
-    struct sip_msg* msg, 
-    char* touser, 
-    int buffersize)
-{
-    struct to_body* to;
-    struct sip_uri uri;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetToUserpart\n");
-
-    touser[0] = '\0';
-
-    if (msg->to != NULL) {
-        if (parse_headers(msg, HDR_TO_F, 0) == 0) {
-            to = get_to(msg);
-            if (parse_uri(to->uri.s, to->uri.len, &uri) == 0) {
-                ospCopyStrToBuffer(&uri.user, touser, buffersize);
-                ospSkipPlus(touser);
-                result = 0;
-            } else {
-                LOG(L_ERR, "osp: ERROR: failed to parse To uri\n");
-            }
-        } else {
-            LOG(L_ERR, "osp: ERROR: failed to parse To header\n");
-        }
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to find To header\n");
-    }
-
-    return result;
-}
-
-/* 
- * Get called number from Request-Line header
- * param msg SIP message
- * param touser User part of To header
- * param buffersize Size of touser buffer
- * return 0 success, -1 failure
- */
-int ospGetUriUserpart(
-    struct sip_msg* msg, 
-    char* uriuser, 
-    int buffersize)
-{
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetUriUserpart\n");
-
-    uriuser[0] = '\0';
-
-    if (parse_sip_msg_uri(msg) >= 0) {
-        ospCopyStrToBuffer(&msg->parsed_uri.user, uriuser, buffersize);
-        ospSkipPlus(uriuser);
-        result = 0;
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to parse Request-Line URI\n");
-    }
-
-    return result;
-}
-
-/* 
- * Append header to SIP message
- * param msg SIP message
- * param header Header to be appended
- * return 0 success, -1 failure
- */
-static int ospAppendHeader(
-    struct sip_msg* msg, 
-    str* header)
-{
-    char* s;
-    struct lump* anchor;
-    
-    LOG(L_DBG, "osp: ospAppendHeader\n");
-
-    if((msg == 0) || (header == 0) || (header->s == 0) || (header->len <= 0)) {
-        LOG(L_ERR, "osp: ERROR: bad parameters for appending header\n");
-        return -1;
-    }
-
-    if (parse_headers(msg, HDR_EOH_F, 0) == -1) {
-        LOG(L_ERR, "osp: ERROR: failed to parse message\n");
-        return -1;
-    }
-
-    anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0, 0);
-    if (anchor == 0) {
-        LOG(L_ERR, "osp: ERROR: failed to get anchor\n");
-        return -1;
-    }
-
-    s = (char*)pkg_malloc(header->len);
-    if (s == 0) {
-        LOG(L_ERR, "osp: ERROR: no memory\n");
-        return -1;
-    }
-
-    memcpy(s, header->s, header->len);
-
-    if (insert_new_lump_before(anchor, s, header->len, 0) == 0) {
-        LOG(L_ERR, "osp: ERROR: failed to insert lump\n");
-        pkg_free(s);
-        return -1;
-    }
-    
-    return 0;
-}
-
-/* 
- * Add OSP token header to SIP message
- * param msg SIP message
- * param token OSP authorization token
- * param tokensize Size of OSP authorization token
- * return 0 success, -1 failure
- */
-int ospAddOspHeader(
-    struct sip_msg* msg, 
-    unsigned char* token, 
-    unsigned int tokensize)
-{
-    str headerval;
-    char buffer[OSP_HEADERBUF_SIZE];
-    unsigned char encodedtoken[OSP_TOKENBUF_SIZE];
-    unsigned int encodedtokensize = sizeof(encodedtoken);
-    int  result = -1;
-
-    LOG(L_DBG, "osp: ospAddOspHeader\n");
-
-    if (tokensize == 0) {
-        LOG(L_DBG, "osp: destination is not OSP device\n");
-        result = 0;
-    } else {
-        if (OSPPBase64Encode(token, tokensize, encodedtoken, &encodedtokensize) == 0) {
-            snprintf(buffer,
-                sizeof(buffer),
-                "%s%.*s\r\n", 
-                OSP_TOKEN_HEADER,
-                encodedtokensize,
-                encodedtoken);
-    
-            headerval.s = buffer;
-            headerval.len = strlen(buffer);
-    
-            LOG(L_DBG, "osp: setting osp token header field '%s'\n", buffer);
-    
-            if (ospAppendHeader(msg, &headerval) == 0) {
-                result = 0;
-            } else {
-                LOG(L_ERR, "osp: ERROR: failed to append osp header\n");
-            }
-        } else {
-            LOG(L_ERR, "osp: ERROR: failed to base64 encode token\n");
-        }
-    }
-
-    return result;
-}
-
-/* 
- * Get OSP token from SIP message
- * param msg SIP message
- * param token OSP authorization token
- * param tokensize Size of OSP authorization token
- * return 0 success, -1 failure
- */
-int ospGetOspHeader(
-    struct sip_msg* msg, 
-    unsigned char* token, 
-    unsigned int* tokensize)
-{
-    struct hdr_field* hf;
-    int errorcode;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetOspHeader\n");
-
-    if (parse_headers(msg, HDR_EOH_F, 0) == -1) {
-        LOG(L_ERR, "osp: ERROR: failed to parse headers\n");
-        return result;
-    }
-
-    for (hf = msg->headers; hf; hf = hf->next) {
-        if ((hf->type == HDR_OTHER_T) && (hf->name.len == OSP_HEADER_SIZE - 2)) {
-            // possible hit
-            if (strncasecmp(hf->name.s, OSP_TOKEN_HEADER, OSP_HEADER_SIZE) == 0) {
-                if ((errorcode = OSPPBase64Decode(hf->body.s, hf->body.len, token, tokensize)) == 0) {
-                    result = 0;
-                } else {
-                    LOG(L_ERR, "osp: ERROR: failed to base64 decode token (%d)\n", errorcode);
-                    LOG(L_ERR, "osp: ERROR: header '%.*s' length %d\n", hf->body.len, hf->body.s, hf->body.len);
-                }
-                break;
-            }        
-        } 
-    }
-
-    return result;
-}
-
-/* 
- * Get first VIA header and use the IP or host name
- * param msg SIP message
- * param sourceaddress Source address
- * param buffersize Size of sourceaddress
- * return 0 success, -1 failure
- */
-int ospGetSourceAddress(
-    struct sip_msg* msg, 
-    char* sourceaddress, 
-    int buffersize)
-{
-    struct via_body* via;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetSourceAddress\n");
-
-    if (msg->h_via1 || (parse_headers(msg, HDR_VIA_F, 0) == 0 && msg->h_via1)) {
-        via = msg->h_via1->parsed;
-        ospCopyStrToBuffer(&via->host, sourceaddress, buffersize);
-        LOG(L_DBG, "osp: source address '%s'\n", sourceaddress);
-        result = 0;
-    }
-
-    return result;
-}
-
-/* 
- * Get Call-ID header from SIP message
- * param msg SIP message
- * param callid Call ID
- * return 0 success, -1 failure
- */
-int ospGetCallId(
-    struct sip_msg* msg, 
-    OSPTCALLID** callid)
-{
-    struct hdr_field* hf;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetCallId\n");
-
-    if (!msg->callid && parse_headers(msg, HDR_CALLID_F, 0) == -1) {
-        LOG(L_ERR, "osp: failed to parse Call-ID\n");
-        return result;
-    }
-
-    hf = (struct hdr_field*)msg->callid;
-    if (hf != NULL) {
-        *callid = OSPPCallIdNew(hf->body.len, (unsigned char*)hf->body.s);
-        if (*callid) {
-            result = 0;
-        } else {
-            LOG(L_ERR, "osp: ERROR: failed to allocate OSPCALLID object for '%.*s'\n", hf->body.len, hf->body.s);
-        }
-    } else {
-        LOG(L_ERR, "osp: ERROR: failed to find Call-ID header\n");
-    }    
-
-    return result;
-}
-
-/* 
- * Get route parameters from the 1st Route or Request-Line
- * param msg SIP message
- * param routeparameters Route parameters
- * param buffersize Size of routeparameters
- * return 0 success, -1 failure
- */
-int ospGetRouteParameters(
-    struct sip_msg* msg, 
-    char* routeparameters, 
-    int buffersize)
-{
-    struct hdr_field* hf;
-    rr_t* rt;
-    struct sip_uri uri;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetRouterParameters\n");
-    LOG(L_DBG, "osp: parsed uri host '%.*s' port '%d' vars '%.*s'\n",
-        msg->parsed_uri.host.len,
-        msg->parsed_uri.host.s,
-        msg->parsed_uri.port_no,
-        msg->parsed_uri.params.len,
-        msg->parsed_uri.params.s);
-
-    if (!(hf = msg->route)) {
-        LOG(L_DBG, "osp: there is no Route headers\n");
-    } else if (!(rt = (rr_t*)hf->parsed)) {
-        LOG(L_ERR, "osp: ERROR: route headers are not parsed\n");
-    } else if (parse_uri(rt->nameaddr.uri.s, rt->nameaddr.uri.len, &uri) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to parse the Route uri '%.*s'\n", rt->nameaddr.uri.len, rt->nameaddr.uri.s);
-    } else if (check_self(&uri.host, uri.port_no ? uri.port_no : SIP_PORT, PROTO_NONE) != 1) {
-        LOG(L_DBG, "osp: the Route uri is NOT mine\n");
-        LOG(L_DBG, "osp: host '%.*s' port '%d'\n", uri.host.len, uri.host.s, uri.port_no);
-        LOG(L_DBG, "osp: params '%.*s'\n", uri.params.len, uri.params.s);
-    } else {
-        LOG(L_DBG, "osp: the Route uri IS mine - '%.*s'\n", uri.params.len, uri.params.s);
-        LOG(L_DBG, "osp: host '%.*s' port '%d'\n", uri.host.len, uri.host.s, uri.port_no);
-        ospCopyStrToBuffer(&uri.params, routeparameters, buffersize);
-        result = 0;
-    }
-
-    if ((result == -1) && (msg->parsed_uri.params.len > 0)) {
-        LOG(L_DBG, "osp: using route parameters from Request-Line uri\n");
-        ospCopyStrToBuffer(&msg->parsed_uri.params, routeparameters, buffersize);
-        routeparameters[msg->parsed_uri.params.len] = '\0';
-        result = 0;
-    }
-
-    return result;
-}
-
-/* 
- * Rebuild URI using called number, destination IP, and port
- * param newuri URI to be built
- * param called Called number
- * param dest Destination IP
- * param port Destination port
- * param format URI format
- * return 0 success, -1 failure
- */
-int ospRebuildDestionationUri(
-    str* newuri, 
-    char* called,
-    char* dest, 
-    char* port,
-    int format) 
-{
-    static const str TRANS = {";transport=tcp", 14};
-    char* buffer;
-    int calledsize;
-    int destsize;
-    int portsize;
-
-    LOG(L_DBG, "osp: ospRebuildDestinationUri\n");
-
-    calledsize = strlen(called);
-    destsize = strlen(dest);
-    portsize = strlen(port);
-
-    LOG(L_DBG, "osp: '%s'(%i) '%s'(%i) '%s'(%i) '%d'\n",
-        called, 
-        calledsize,
-        dest, 
-        destsize, 
-        port, 
-        portsize,
-        format); 
-
-    /* "sip:" + called + "@" + dest + : + port + " SIP/2.0" for URI format 0 */
-    /* "<sip:" + called + "@" + dest + : + port> + " SIP/2.0" for URI format 1 */
-    newuri->s = (char*)pkg_malloc(1 + 4 + calledsize + 1 + destsize + 1 + portsize + 1 + 1 + 16 + TRANS.len);
-    if (newuri == NULL) {
-        LOG(L_ERR, "osp: ERROR: no memory\n");
-        return -1;
-    }    
-    buffer = newuri->s;
-
-    if (format == 1) {
-      *buffer++ = '<';
-    }
-    *buffer++ = 's';
-    *buffer++ = 'i';
-    *buffer++ = 'p';
-    *buffer++ = ':';
-
-    memcpy(buffer, called, calledsize);
-    buffer += calledsize;
-    *buffer++ = '@';
-    
-    if (*dest == '[') {
-        /* leave out annoying [] */
-        memcpy(buffer, dest + 1, destsize - 2);
-        buffer += destsize - 2;
-    } else {
-        memcpy(buffer, dest, destsize);
-        buffer += destsize;
-    }
-    
-    if (portsize > 0) {
-        *buffer++ = ':';
-        memcpy(buffer, port, portsize);
-        buffer += portsize;
-    }
-
-    if (format == 1) {
-      *buffer++ = '>';
-    }
-
-/*    
-    *buffer++ = ' ';
-    *buffer++ = 'S';
-    *buffer++ = 'I';
-    *buffer++ = 'P';
-    *buffer++ = '/';
-    *buffer++ = '2';
-    *buffer++ = '.';
-    *buffer++ = '0';
-
-    memcpy(buffer, TRANS.s, TRANS.len);
-    buffer += TRANS.len;
-    *buffer = '\0';
-*/
-
-    newuri->len = buffer - newuri->s;
-
-    LOG(L_DBG, "osp: new uri '%.*s'\n", newuri->len, newuri->s);
-
-    return 0;
-}
-
-/* 
- * Get next hop using the first Route not generated by this proxy or URI from the Request-Line
- * param msg SIP message
- * param nexthop Next hop IP
- * param buffersize Size of nexthop
- */
-void ospGetNextHop(
-    struct sip_msg* msg, 
-    char* nexthop, 
-    int buffersize)
-{
-    struct hdr_field* hf;
-    struct sip_uri uri;
-    rr_t* rt;
-    int found = 0;
-
-    LOG(L_DBG, "osp: ospGetNextHop\n");
-
-    for (hf = msg->headers; hf; hf = hf->next) {
-        if (hf->type == HDR_ROUTE_T) {
-            for (rt = (rr_t*)hf->parsed; rt; rt = rt->next) {
-                if (parse_uri(rt->nameaddr.uri.s, rt->nameaddr.uri.len, &uri) == 0) {
-                    LOG(L_DBG, "osp: host '%.*s' port '%d'\n", uri.host.len, uri.host.s, uri.port_no);
-
-                    if (check_self(&uri.host, uri.port_no ? uri.port_no : SIP_PORT, PROTO_NONE) != 1) {
-                        LOG(L_DBG, "osp: it is NOT me, FOUND!\n");
-
-                        ospCopyStrToBuffer(&uri.host, nexthop, buffersize);
-                        found = 1;
-                        break;
-                    } else {
-                        LOG(L_DBG, "osp: it IS me, keep looking\n");
-                    }
-                } else {
-                    LOG(L_ERR, 
-                        "osp: ERROR: failed to parsed route uri '%.*s'\n", 
-                        rt->nameaddr.uri.len, 
-                        rt->nameaddr.uri.s);
-                }
-            }
-            if (found == 1) {
-                break;
-            }
-        }
-    }
-
-    if (!found) {
-        LOG(L_DBG, "osp: using the Request-Line instead host '%.*s' port '%d'\n",
-             msg->parsed_uri.host.len,
-             msg->parsed_uri.host.s,
-             msg->parsed_uri.port_no);
-
-        ospCopyStrToBuffer(&msg->parsed_uri.host, nexthop, buffersize);
-        found = 1;
-    }
-}
-
-/* 
- * Get direction using the first Route not generated by this proxy or URI from the Request-Line
- *     SER does not have is_direction as OpenSER. We have to write it.
- *     The problem is we cannot check append_fromtag option before running. So, ftag may not exist.
- * param msg SIP message
- * return 0 originating, 1 terminating, -1 failed 
- */
-int ospGetDirection(struct sip_msg* msg)
-{
-    static const str FTAG = {"ftag", 4};
-    char parameters[OSP_HEADERBUF_SIZE];
-    char* tmp;
-    char* token;
-    str ftag;
-    struct to_body* from;
-    int result = -1;
-
-    LOG(L_DBG, "osp: ospGetDirection\n");
-
-    if (ospGetRouteParameters(msg, parameters, sizeof(parameters)) == 0) {
-        for (token = strtok_r(parameters, ";", &tmp);
-             token;
-             token = strtok_r(NULL, ";", &tmp))
-        {
-            ftag.s = token;
-            ftag.len = strlen(token);
-
-            /* Remove leading white space char */
-            trim_leading(&ftag);
-
-            if (strncmp(ftag.s, FTAG.s, FTAG.len) == 0) {
-                /* Remove "ftag" string */
-                ftag.s += FTAG.len;
-                ftag.len -= FTAG.len;
-
-                /* Remove leading white space char */
-                trim_leading(&ftag);
-
-                /* Remove '=' char */
-                ftag.s++;
-                ftag.len--;
-
-                /* Remove leading and tailing white space char */
-                trim(&ftag);
-
-                LOG(L_DBG, "osp: ftag '%s'\n", ftag.s);
-
-                if ((parse_from_header(msg) == 0) && ((from = get_from(msg)) != 0)) {
-                    if ((ftag.len == from->tag_value.len) && !strncmp(ftag.s, from->tag_value.s, ftag.len)) {
-                        LOG(L_DBG, "osp: originating\n");
-                        result = 0;
-                    } else {
-                        LOG(L_DBG, "osp: terminating\n");
-                        result = 1;
-                    }
-                }
-                break;
-            } else {
-                LOG(L_DBG, "osp: ignoring parameter '%s'\n", token);
-            }
-        }
-    }
-
-    return result;
-}

+ 0 - 60
modules_s/osp/sipheader.h

@@ -1,60 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_SIPHEADER_H_
-#define _OSP_MOD_SIPHEADER_H_
-
-#include <osp/osp.h>
-#include "../../parser/msg_parser.h"
-
-#define OSP_TOKEN_HEADER    "P-OSP-Auth-Token: "
-#define OSP_HEADER_SIZE     strlen(OSP_TOKEN_HEADER)
-
-void ospCopyStrToBuffer(str* source, char* buffer, int buffersize);
-int ospGetFromUserpart(struct sip_msg* msg, char* fromuser, int buffersize);
-int ospGetRpidUserpart(struct sip_msg* msg, char* fromuser, int buffersize);
-int ospGetToUserpart(struct sip_msg* msg, char* touser, int buffersize);
-int ospGetUriUserpart(struct sip_msg* msg, char* touser, int buffersize);
-int ospAddOspHeader(struct sip_msg* msg, unsigned char* token, unsigned int tokensize);
-int ospGetOspHeader(struct sip_msg* msg, unsigned char* token, unsigned int* tokensize);
-int ospGetSourceAddress(struct sip_msg* msg, char* sourceaddress, int buffersize);
-int ospGetCallId(struct sip_msg* msg, OSPTCALLID** callid);
-int ospGetRouteParameters(struct sip_msg* msg, char* routeparams, int buffersize);
-int ospRebuildDestionationUri(str* newuri, char* called, char* dest, char* port, int format);
-void ospGetNextHop(struct sip_msg* msg, char* nexthop, int buffersize);
-int ospGetDirection(struct sip_msg* msg);
-
-#endif /* _OSP_MOD_SIPHEADER_H_ */
-

+ 0 - 203
modules_s/osp/term_transaction.c

@@ -1,203 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "osp_mod.h"
-#include "term_transaction.h"
-#include "sipheader.h"
-#include "destination.h"
-#include "osptoolkit.h"
-#include "usage.h"
-
-extern char* _osp_device_ip;
-extern int _osp_token_format;
-extern int _osp_validate_callid;
-extern OSPTPROVHANDLE _osp_provider;
-
-/*
- * Get OSP token
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospCheckHeader(
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    unsigned char buffer[OSP_TOKENBUF_SIZE];
-    unsigned int  buffersize = sizeof(buffer);
-
-    LOG(L_DBG, "osp: ospCheckHeader\n");
-
-    if (ospGetOspHeader(msg, buffer, &buffersize) != 0) {
-        return MODULE_RETURNCODE_FALSE;
-    } else {
-        return MODULE_RETURNCODE_TRUE;
-    }
-}
-
-/*
- * Validate OSP token
- * param ignore1
- * param ignore2
- * return  MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospValidateHeader (
-    struct sip_msg* msg, 
-    char* ignore1, 
-    char* ignore2)
-{
-    int errorcode; 
-    OSPTTRANHANDLE transaction = -1;
-    unsigned int authorized = 0;
-    unsigned int timelimit = 0;
-    void* detaillog = NULL;
-    unsigned int logsize = 0;
-    unsigned char* callidval = (unsigned char*)"";
-    OSPTCALLID* callid = NULL;
-    unsigned callidsize = 0;
-    unsigned char token[OSP_TOKENBUF_SIZE];
-    unsigned int tokensize = sizeof(token);
-    osp_dest dest;
-    int result = MODULE_RETURNCODE_FALSE;
-
-    LOG(L_DBG, "osp: ospValidateHeader\n");
-
-    ospInitDestination(&dest);
-
-    if ((errorcode = OSPPTransactionNew(_osp_provider, &transaction) != OSPC_ERR_NO_ERROR)) {
-        LOG(L_ERR, "osp: ERROR: failed to create a new OSP transaction handle (%d)\n", errorcode);
-    } else if ((ospGetRpidUserpart(msg, dest.calling, sizeof(dest.calling)) != 0) && 
-        (ospGetFromUserpart(msg, dest.calling, sizeof(dest.calling)) != 0))
-    {
-        LOG(L_ERR, "osp: ERROR: failed to extract calling number\n");
-    } else if ((ospGetUriUserpart(msg, dest.called, sizeof(dest.called)) != 0) &&
-        (ospGetToUserpart(msg, dest.called, sizeof(dest.called)) != 0))
-    {
-        LOG(L_ERR, "osp: ERROR: failed to extract called number\n");
-    } else if (ospGetCallId(msg, &callid) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to extract call id\n");
-    } else if (ospGetSourceAddress(msg, dest.source, sizeof(dest.source)) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to extract source address\n");
-    } else if (ospGetOspHeader(msg, token, &tokensize) != 0) {
-        LOG(L_ERR, "osp: ERROR: failed to extract OSP authorization token\n");
-    } else {
-        LOG(L_INFO, 
-            "osp: validate token for: "
-            "transaction_handle '%i' "
-            "e164_source '%s' "
-            "e164_dest '%s' "
-            "validate_call_id '%s' "
-            "call_id '%.*s'\n",
-            transaction,
-            dest.calling,
-            dest.called,
-            _osp_validate_callid == 0 ? "No" : "Yes",
-            callid->ospmCallIdLen,
-            callid->ospmCallIdVal);
-
-        if (_osp_validate_callid != 0) {
-            callidsize = callid->ospmCallIdLen;
-            callidval = callid->ospmCallIdVal;
-        }
-
-        errorcode = OSPPTransactionValidateAuthorisation(
-            transaction,
-            "",
-            "",
-            "",
-            "",
-            dest.calling,
-            OSPC_E164,
-            dest.called,
-            OSPC_E164,
-            callidsize,
-            callidval,
-            tokensize,
-            token,
-            &authorized,
-            &timelimit,
-            &logsize,
-            detaillog,
-            _osp_token_format);
-    
-        if (callid->ospmCallIdLen > sizeof(dest.callid) - 1) {
-            dest.callidsize = sizeof(dest.callid) - 1;
-        } else {
-            dest.callidsize = callid->ospmCallIdLen;
-        }
-        memcpy(dest.callid, callid->ospmCallIdVal, dest.callidsize);
-        dest.callid[dest.callidsize] = 0;
-        dest.transid = ospGetTransactionId(transaction);
-        dest.type = OSPC_DESTINATION;
-        dest.authtime = time(NULL);
-        strncpy(dest.host, _osp_device_ip, sizeof(dest.host) - 1);
-
-        ospSaveTermDestination(&dest);
-
-        if ((errorcode == OSPC_ERR_NO_ERROR) && (authorized == 1)) {
-            LOG(L_DBG, 
-                "osp: call is authorized for %d seconds, call_id '%.*s' transaction_id '%llu'",
-                timelimit,
-                dest.callidsize,
-                dest.callid,
-                dest.transid);
-            ospRecordTermTransaction(msg, dest.transid, dest.source, dest.calling, dest.called, dest.authtime);
-            result = MODULE_RETURNCODE_TRUE;
-        } else {
-            LOG(L_ERR, "osp: ERROR: token is invalid (%i)\n", errorcode);
-
-            /* 
-             * Update terminating status code to 401 and report terminating setup usage.
-             * We may need to make 401 configurable, just in case a user decides to reply with
-             * a different code.  Other options - trigger call setup usage reporting from the cpl
-             * (after replying with an error code), or maybe use a different tm callback.
-             */
-            ospRecordEvent(0, 401);
-        }
-    }
-
-    if (transaction != -1) {
-        OSPPTransactionDelete(transaction);
-    }
-
-    if (callid != NULL) {
-        OSPPCallIdDelete(&callid);
-    }
-    
-    return result;
-}
-

+ 0 - 45
modules_s/osp/term_transaction.h

@@ -1,45 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_TERM_TRANSACTION_H_
-#define _OSP_MOD_TERM_TRANSACTION_H_
-
-#include "../../parser/msg_parser.h"
-
-int ospCheckHeader(struct sip_msg*, char*, char*);
-int ospValidateHeader(struct sip_msg*, char*, char*);
-
-#endif /* _OSP_MOD_TERM_TRANSACTION_H_ */
-

+ 0 - 158
modules_s/osp/tm.c

@@ -1,158 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include "../../modules/tm/tm_load.h"
-#include "tm.h"
-#include "destination.h"
-
-struct tm_binds osp_tmb;
-
-static void ospOnReq(struct cell* t, int type, struct tmcb_params* ps);
-static void ospTmcbFunc(struct cell* t, int type, struct tmcb_params* ps);
-
-/*
- * Load TM API
- * return 0 success, -1 failure
- */
-int ospInitTm(void)
-{
-    load_tm_f load_tm;
-
-    LOG(L_DBG, "osp: ospInitTm\n");
-
-    if ((load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0)) == 0) {
-        LOG(L_ERR, "osp: ERROR: failed to import load_tm\n");
-        return -1;
-    }
-
-    if (load_tm(&osp_tmb) == -1) {
-        LOG(L_ERR, "osp: ERROR: failed to load TM API\n");
-        LOG(L_ERR, "osp: ERROR: TM is required for reporting call setup usage\n");
-        return -1;
-    }
-
-    /* Register callbacks, listen for all incoming requests  */
-    if (osp_tmb.register_tmcb(0, 0, TMCB_REQUEST_IN, ospOnReq, 0, 0) <= 0) {
-        LOG(L_ERR, "osp: ERROR: failed to register TMCB_REQUEST_IN callback\n");
-        LOG(L_ERR, "osp: ERROR: TM callbacks are required for reporting call set up usage\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-/*
- * Register OSP callback function
- * param t
- * param type
- * param ps
- */
-static void ospOnReq(
-    struct cell* t, 
-    int type, 
-    struct tmcb_params* ps)
-{
-    int tmcb_types;
-
-    LOG(L_DBG, "osp: ospOnReq\n");
-
-    /* install addaitional handlers */
-    tmcb_types =
-//        TMCB_REQUEST_FWDED |
-//        TMCB_RESPONSE_FWDED |
-        TMCB_ON_FAILURE | 
-//        TMCB_LOCAL_COMPLETED |
-        /* report on completed transactions */
-        TMCB_RESPONSE_OUT |
-        /* account e2e acks if configured to do so */
-        TMCB_E2EACK_IN |
-        /* report on missed calls */
-        TMCB_ON_FAILURE_RO |
-        /* get incoming replies ready for processing */
-//        TMCB_RESPONSE_IN |
-        0;
-
-    if (osp_tmb.register_tmcb(0, t, tmcb_types, ospTmcbFunc, 0, 0) <= 0) {
-        LOG(L_ERR, "osp: ERROR: failed to register TM callbacks\n");
-        LOG(L_ERR, "osp: ERROR: TM callbacks are required for reporting call setup usage\n");
-        return;
-    }
-
-    /* Also, if that is INVITE, disallow silent t-drop */
-    if (ps->req->REQ_METHOD == METHOD_INVITE) {
-        LOG(L_DBG, "osp: noisy_timer set for accounting\n");
-        t->flags |= T_NOISY_CTIMER_FLAG;
-    }
-}
-
-/*
- * OSP callback function
- * param t
- * param type
- * param ps
- */
-static void ospTmcbFunc(
-    struct cell* t, 
-    int type, 
-    struct tmcb_params* ps)
-{
-    LOG(L_DBG, "osp: ospTmcbFunc\n");
-
-    if (type & TMCB_RESPONSE_OUT) {
-        LOG(L_DBG, "osp: RESPONSE_OUT\n");
-    } else if (type & TMCB_E2EACK_IN) {
-        LOG(L_DBG, "osp: E2EACK_IN\n");
-    } else if (type & TMCB_ON_FAILURE_RO) {
-        LOG(L_DBG, "osp: FAILURE_RO\n");
-    } else if (type & TMCB_RESPONSE_IN) {
-        LOG(L_DBG, "osp: RESPONSE_IN\n");
-    } else if (type & TMCB_REQUEST_FWDED) {
-        LOG(L_DBG, "osp: REQUEST_FWDED\n");
-    } else if (type & TMCB_RESPONSE_FWDED) {
-        LOG(L_DBG, "osp: RESPONSE_FWDED\n");
-    } else if (type & TMCB_ON_FAILURE) {
-        LOG(L_DBG, "osp: FAILURE\n");
-    } else if (type & TMCB_LOCAL_COMPLETED) {
-        LOG(L_DBG, "osp: COMPLETED\n");
-    } else {
-        LOG(L_DBG, "osp: something else '%d'\n", type);
-    }
-
-    if (t) {
-        ospRecordEvent(t->uac[t->nr_of_outgoings - 1].last_received, t->uas.status);
-    } else {
-        LOG(L_DBG, "osp: cell is empty\n");
-    }
-}

+ 0 - 47
modules_s/osp/tm.h

@@ -1,47 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_TM_H_
-#define _OSP_MOD_TM_H_
-
-/* 
- * Register for tm events and use them to record and report information
- * about the call set up transaction - return codes, call start, alert and
- * connect times, etc.
- */
-int ospInitTm(void);
-
-#endif /* _OSP_MOD_TM_H_ */
-

+ 0 - 627
modules_s/osp/usage.c

@@ -1,627 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <osp/osp.h>
-#include "../../sr_module.h"
-#include "../../usr_avp.h"
-#include "usage.h"
-#include "destination.h"
-#include "osptoolkit.h"
-#include "sipheader.h"
-
-#define OSP_ORIG_COOKIE     "osp-o"
-#define OSP_TERM_COOKIE     "osp-t"
-
-#define OSP_RELEASE_ORIG    0
-#define OSP_RELEASE_TERM    1
-
-/* The up case tags for the destinations may corrupt OSP cookies */
-#define OSP_COOKIE_TRANSID      't'
-#define OSP_COOKIE_TRANSIDUP    'T'
-#define OSP_COOKIE_SRCIP        's'
-#define OSP_COOKIE_SRCIPUP      'S'
-#define OSP_COOKIE_AUTHTIME     'a'
-#define OSP_COOKIE_AUTHTIMEUP   'A'
-#define OSP_COOKIE_DSTCOUNT     'c'
-#define OSP_COOKIE_DSTCOUNTUP   'C'
-
-/* SER uses AVP to add RR pararmters */
-const str OSP_ORIGCOOKIE_NAME = {"_osp_orig_cookie_", 17};
-const str OSP_TERMCOOKIE_NAME = {"_osp_term_cookie_", 17};
-
-extern char* _osp_device_ip;
-extern OSPTPROVHANDLE _osp_provider;
-extern str OSP_ORIGDEST_NAME;
-
-static void ospRecordTransaction(struct sip_msg* msg, unsigned long long transid, char* uac, char* from, char* to, time_t authtime, int isorig, unsigned destinationCount);
-static int ospBuildUsageFromDestination(OSPTTRANHANDLE transaction, osp_dest* dest, int lastcode);
-static int ospReportUsageFromDestination(OSPTTRANHANDLE transaction, osp_dest* dest);
-/* SER checks ftag by itself, without release parameter */
-static int ospReportUsageFromCookie(struct sip_msg* msg, char* cooky, OSPTCALLID* callid, OSPE_MSG_ROLETYPES type);
-
-/*
- * Create OSP cookie and insert it into Record-Route header
- * param msg SIP message
- * param tansid Transaction ID
- * param uac Source IP
- * param from
- * param to
- * param authtime Request authorization time
- * param isorig Originate / Terminate
- * param destinationCount Destination count
- */
-static void ospRecordTransaction(
-    struct sip_msg* msg, 
-    unsigned long long transid,
-    char* uac, 
-    char* from, 
-    char* to, 
-    time_t authtime, 
-    int isorig,
-    unsigned destinationCount)
-{
-    const str* name;
-    str cookie;
-    char buffer[OSP_STRBUF_SIZE];
-
-    LOG(L_DBG, "osp: ospRecordTransaction\n");
-
-    cookie.s = buffer;
-
-    if (isorig == 1) {
-        cookie.len = snprintf(
-            buffer,
-            sizeof(buffer),
-            "%c%llu_%c%s_%c%d_%c%d",
-            OSP_COOKIE_TRANSID,
-            transid,
-            OSP_COOKIE_SRCIP,
-            uac,
-            OSP_COOKIE_AUTHTIME,
-            (unsigned int)authtime,
-            OSP_COOKIE_DSTCOUNT,
-            destinationCount);
-    } else {
-        cookie.len = snprintf(
-            buffer,
-            sizeof(buffer),
-            "%c%llu_%c%s_%c%d",
-            OSP_COOKIE_TRANSID,
-            transid,
-            OSP_COOKIE_SRCIP,
-            uac,
-            OSP_COOKIE_AUTHTIME,
-            (unsigned int)authtime);
-    }
-
-    if (cookie.len < 0) {
-        LOG(L_ERR, "osp: ERROR: failed to create OSP cookie\n");
-        return;
-    }
-
-    /* SER uses AVP to add RR parameters */
-    LOG(L_DBG, "osp: adding RR parameter '%s' for '%s'\n", 
-        buffer, 
-        (isorig == 1) ? "orig" : "term");
-    name = (isorig == 1) ? &OSP_ORIGCOOKIE_NAME : &OSP_TERMCOOKIE_NAME;
-    add_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)*name, (int_str)cookie);
-}
-
-/*
- * Create OSP originate cookie and insert it into Record-Route header
- * param msg SIP message
- * param tansid Transaction ID
- * param uac Source IP
- * param from
- * param to
- * param authtime Request authorization time
- * param destinationCount Destination count
- */
-void ospRecordOrigTransaction(
-    struct sip_msg* msg, 
-    unsigned long long transid, 
-    char* uac, 
-    char* from, 
-    char* to, 
-    time_t authtime,
-    unsigned destinationCount)
-{
-    int isorig = 1;
-
-    LOG(L_DBG, "osp: ospRecordOrigTransaction\n");
-
-    ospRecordTransaction(msg, transid, uac, from, to, authtime, isorig, destinationCount);
-}
-
-/*
- * Create OSP terminate cookie and insert it into Record-Route header
- * param msg SIP message
- * param tansid Transaction ID
- * param uac Source IP
- * param from
- * param to
- * param authtime Request authorization time
- */
-void ospRecordTermTransaction(
-    struct sip_msg* msg, 
-    unsigned long long transid, 
-    char* uac, 
-    char* from, 
-    char* to, 
-    time_t authtime)
-{
-    int isorig = 0;
-    unsigned destinationCount = 0; /* N/A */
-
-    LOG(L_DBG, "osp: ospRecordTermTransaction\n");
-
-    ospRecordTransaction(msg, transid, uac, from, to, authtime, isorig, destinationCount);
-}
-
-/*
- * Report OSP usage from OSP cookie
- *     SER checks ftag by itself, without release parameter
- * param msg SIP message
- * param cookie OSP cookie
- * param callid Call ID
- * param type Usage type
- * return
- */
-static int ospReportUsageFromCookie(
-    struct sip_msg* msg,
-    char* cookie, 
-    OSPTCALLID* callid, 
-    OSPE_MSG_ROLETYPES type)
-{
-    int release;
-    char* tmp;
-    char* token;
-    char tag;
-    char* value;
-    unsigned long long transid = 0;
-    time_t authtime = 0;
-    unsigned destinationCount = 0;
-    time_t endtime = time(NULL);
-    char firstvia[OSP_STRBUF_SIZE];
-    char from[OSP_STRBUF_SIZE];
-    char to[OSP_STRBUF_SIZE];
-    char nexthop[OSP_STRBUF_SIZE];
-    char* calling;
-    char* called;
-    char* originator = NULL;
-    char* terminator;
-    char* source;
-    char srcbuf[OSP_STRBUF_SIZE];
-    char* destination;
-    char dstbuf[OSP_STRBUF_SIZE];
-    char* srcdev;
-    char devbuf[OSP_STRBUF_SIZE];
-    OSPTTRANHANDLE transaction = -1;
-    int errorcode;
-
-    LOG(L_DBG, "osp: ospReportUsageFromCookie\n");
-
-    LOG(L_DBG, "osp: '%s' type '%d'\n", cookie, type);
-    if (cookie != NULL) {
-        for (token = strtok_r(cookie, "_", &tmp);
-            token;
-            token = strtok_r(NULL, "_", &tmp))
-        {
-            tag = *token;
-            value= token + 1;
-
-            switch (tag) {
-                case OSP_COOKIE_TRANSID:
-                case OSP_COOKIE_TRANSIDUP:
-                    transid = atoll(value);
-                    break;
-                case OSP_COOKIE_AUTHTIME:
-                case OSP_COOKIE_AUTHTIMEUP:
-                    authtime = atoi(value);
-                    break;
-                case OSP_COOKIE_SRCIP:
-                case OSP_COOKIE_SRCIPUP:
-                    originator = value;
-                    break;
-                case OSP_COOKIE_DSTCOUNT:
-                case OSP_COOKIE_DSTCOUNTUP:
-                    destinationCount = (unsigned)atoi(value);
-                    break;
-                default:
-                    LOG(L_ERR, "osp: ERROR: unexpected tag '%c' / value '%s'\n", tag, value);
-                    break;
-            }
-        }
-    }
-
-    ospGetSourceAddress(msg, firstvia, sizeof(firstvia));
-    ospGetFromUserpart(msg, from, sizeof(from));
-    ospGetToUserpart(msg, to, sizeof(to));
-    ospGetNextHop(msg, nexthop, sizeof(nexthop));
-
-    LOG(L_DBG, "osp: first via '%s' from '%s' to '%s' next hop '%s'\n",
-        firstvia,
-        from,
-        to,
-        nexthop);
-
-    /* SER checks ftag by itself */
-    errorcode = ospGetDirection(msg);
-    switch (errorcode) {
-        case 0:
-            release = OSP_RELEASE_ORIG;
-            break;
-        case 1:
-            release = OSP_RELEASE_TERM;
-            break;
-        default:
-            /* This approach has a problem of flipping called/calling number */
-            if (strcmp(firstvia, originator) == 0) {
-                release = OSP_RELEASE_ORIG;
-            } else {
-                release = OSP_RELEASE_TERM;
-            }
-    }
-
-    if (release == OSP_RELEASE_ORIG) {
-        LOG(L_DBG,
-            "osp: orig '%s' released the call, call_id '%.*s' transaction_id '%llu'\n",
-            firstvia,
-            callid->ospmCallIdLen,
-            callid->ospmCallIdVal,
-            transid);
-        if (originator == NULL) {
-            originator = firstvia;
-        }
-        calling = from;
-        called = to;
-        terminator = nexthop;
-    } else {
-        release = OSP_RELEASE_TERM;
-        LOG(L_DBG,
-            "osp: term '%s' released the call, call_id '%.*s' transaction_id '%llu'\n",
-            firstvia,
-            callid->ospmCallIdLen,
-            callid->ospmCallIdVal,
-            transid);
-        if (originator == NULL) {
-            originator = nexthop;
-        }
-        calling = to;
-        called = from;
-        terminator = firstvia;
-    }
-
-    errorcode = OSPPTransactionNew(_osp_provider, &transaction);
-
-    LOG(L_DBG, "osp: created transaction handle '%d' (%d)\n", transaction, errorcode);
-
-    switch (type) {
-        case OSPC_DESTINATION:
-            ospConvertAddress(originator, srcbuf, sizeof(srcbuf));
-            source = srcbuf;
-            destination = _osp_device_ip;
-            srcdev = "";
-            break;
-        case OSPC_SOURCE:
-        case OSPC_OTHER:
-        case OSPC_UNDEFINED_ROLE:
-        default:
-            source = _osp_device_ip;
-            ospConvertAddress(terminator, dstbuf, sizeof(dstbuf));
-            destination = dstbuf;
-            ospConvertAddress(originator, devbuf, sizeof(devbuf));
-            srcdev = devbuf;
-            break;
-    }
-
-    errorcode = OSPPTransactionBuildUsageFromScratch(
-        transaction,
-        transid,
-        type,
-        source,
-        destination,
-        srcdev,
-        "",
-        calling,
-        OSPC_E164,
-        called,
-        OSPC_E164,
-        callid->ospmCallIdLen,
-        callid->ospmCallIdVal,
-        (enum OSPEFAILREASON)0,
-        NULL,
-        NULL);
-
-    LOG(L_DBG, "osp: built usage handle '%d' (%d)\n", transaction, errorcode);
-
-    if ((errorcode == OSPC_ERR_NO_ERROR) && (destinationCount > 0)) {
-        errorcode = OSPPTransactionSetDestinationCount(
-            transaction,
-            destinationCount);
-    }
-
-    ospReportUsageWrapper(
-        transaction,
-        cookie == NULL ? 9016 : 10016,
-        cookie == NULL ? 0 : endtime - authtime,
-        authtime,
-        endtime,
-        0,0,
-        0,0,
-        release);
-
-    return errorcode;
-}
-
-/*
- * Report OSP usage
- *     SER uses AVP to add RR pararmters
- * param msg SIP message
- * param ignore1
- * param ignore2
- * return MODULE_RETURNCODE_TRUE success, MODULE_RETURNCODE_FALSE failure
- */
-int ospReportUsage(
-    struct sip_msg* msg, 
-    char* ignore1,
-    char* ignore2)
-{
-    int_str cookieval;
-    struct usr_avp* cookieavp = NULL;
-    static const int FROMFLAGS = AVP_TRACK_FROM | AVP_CLASS_URI | AVP_NAME_STR | AVP_VAL_STR;
-    static const int TOFLAGS = AVP_TRACK_TO | AVP_CLASS_URI | AVP_NAME_STR | AVP_VAL_STR;
-    char buffer[OSP_HEADERBUF_SIZE];
-    OSPTCALLID* callid = NULL;
-    int result = MODULE_RETURNCODE_FALSE;
-
-    LOG(L_DBG, "osp: ospReportUsage\n");
-
-    ospGetCallId(msg, &callid);
-
-    if (callid != NULL) {
-        if ((cookieavp = search_first_avp(FROMFLAGS, (int_str)OSP_ORIGCOOKIE_NAME, &cookieval, NULL)) != 0 ||
-            (cookieavp = search_first_avp(TOFLAGS, (int_str)OSP_ORIGCOOKIE_NAME, &cookieval, NULL)) != 0)
-        {
-            ospCopyStrToBuffer(&cookieval.s, buffer, sizeof(buffer));
-            LOG(L_DBG, "orig cookie '%s'\n", buffer);
-            LOG(L_INFO,
-                "osp: report orig duration for call_id '%.*s'\n",
-                callid->ospmCallIdLen,
-                callid->ospmCallIdVal);
-            ospReportUsageFromCookie(msg, buffer, callid, OSPC_SOURCE);
-            result = MODULE_RETURNCODE_TRUE;
-        }
-
-        if ((cookieavp = search_first_avp(FROMFLAGS, (int_str)OSP_TERMCOOKIE_NAME, &cookieval, NULL)) != 0 ||
-            (cookieavp = search_first_avp(TOFLAGS, (int_str)OSP_TERMCOOKIE_NAME, &cookieval, NULL)) != 0)
-        {
-            ospCopyStrToBuffer(&cookieval.s, buffer, sizeof(buffer));
-            LOG(L_DBG, "term cookie '%s'\n", buffer);
-            LOG(L_INFO,
-                "osp: report term duration for call_id '%.*s'\n",
-                callid->ospmCallIdLen,
-                callid->ospmCallIdVal);
-            ospReportUsageFromCookie(msg, buffer, callid, OSPC_DESTINATION);
-            result = MODULE_RETURNCODE_TRUE;
-        }
-
-        if (result == MODULE_RETURNCODE_FALSE) {
-            LOG(L_DBG, "without orig or term OSP information\n");
-            LOG(L_INFO, "report other duration for call_id '%.*s'\n",
-               callid->ospmCallIdLen,
-               callid->ospmCallIdVal);
-            ospReportUsageFromCookie(msg, NULL, callid, OSPC_SOURCE);
-            result = MODULE_RETURNCODE_TRUE;
-        }
-
-        OSPPCallIdDelete(&callid);
-    }
-
-    if (result == MODULE_RETURNCODE_FALSE) {
-        LOG(L_DBG, "osp: failed to report usage\n");
-    }
-
-    return result;
-}
-
-/*
- * Build OSP usage from destination
- * param transaction OSP transaction handle
- * param dest Destination
- * param lastcode Destination status
- * return 0 success, others failure
- */
-static int ospBuildUsageFromDestination(
-    OSPTTRANHANDLE transaction, 
-    osp_dest* dest, 
-    int lastcode)
-{
-    int errorcode;
-    char addr[OSP_STRBUF_SIZE];
-    char* source;
-    char* srcdev;
-
-    LOG(L_DBG, "osp: ospBuildUsageFromDestination\n");
-
-    if (dest->type == OSPC_SOURCE) {
-        ospConvertAddress(dest->srcdev, addr, sizeof(addr));
-        source = dest->source;
-        srcdev = addr;
-    } else {
-        ospConvertAddress(dest->source, addr, sizeof(addr));
-        source = addr;
-        srcdev = dest->srcdev;
-    }
-
-    errorcode = OSPPTransactionBuildUsageFromScratch(
-        transaction,
-        dest->transid,
-        dest->type,
-        source,
-        dest->host,
-        srcdev,
-        dest->destdev,
-        dest->calling,
-        OSPC_E164,
-        dest->origcalled,       /* Report original called number */
-        OSPC_E164,
-        dest->callidsize,
-        dest->callid,
-        (enum OSPEFAILREASON)lastcode,
-        NULL,
-        NULL);
-
-    return errorcode;
-}
-
-/*
- * Report OSP usage from destination
- * param transaction OSP transaction handle
- * param dest Destination
- * return 0 success
- */
-static int ospReportUsageFromDestination(
-    OSPTTRANHANDLE transaction, 
-    osp_dest* dest)
-{
-    ospReportUsageWrapper(
-        transaction,                                          /* In - Transaction handle */
-        dest->lastcode,                                       /* In - Release Code */    
-        0,                                                    /* In - Length of call */
-        dest->authtime,                                       /* In - Call start time */
-        0,                                                    /* In - Call end time */
-        dest->time180,                                        /* In - Call alert time */
-        dest->time200,                                        /* In - Call connect time */
-        dest->time180 ? 1 : 0,                                /* In - Is PDD Info present */
-        dest->time180 ? dest->time180 - dest->authtime : 0,   /* In - Post Dial Delay */
-        0);
-
-    return 0;
-}
-
-/*
- * Report originate call setup usage
- */
-void ospReportOrigSetupUsage(void)
-{
-    osp_dest* dest = NULL;
-    osp_dest* lastused = NULL;
-    struct usr_avp* destavp = NULL;
-    int_str destval;
-    struct search_state state;
-    OSPTTRANHANDLE transaction = -1;
-    int lastcode = 0;
-    int errorcode;
-
-    LOG(L_DBG, "osp: ospReportOrigSetupUsage\n");
-
-    errorcode = OSPPTransactionNew(_osp_provider, &transaction);
-
-    for (destavp = search_first_avp(AVP_NAME_STR | AVP_VAL_STR, (int_str)OSP_ORIGDEST_NAME, &destval, &state);
-        destavp != NULL;
-        destavp = search_next_avp(&state, &destval)) 
-    {
-        /* OSP destination is wrapped in a string */
-        dest = (osp_dest*)destval.s.s;
-
-        if (dest->used == 1) {
-            if (dest->reported == 1) {
-                LOG(L_DBG, "osp: orig setup already reported\n");
-                break;
-            } else {
-                dest->reported = 1;
-            }
-
-            LOG(L_DBG, "osp: iterating through used destination\n");
-
-            ospDumpDestination(dest);
-
-            lastused = dest;
-
-            errorcode = ospBuildUsageFromDestination(transaction, dest, lastcode);
-
-            lastcode = dest->lastcode;
-        } else {
-            LOG(L_DBG, "osp: destination has not been used, breaking out\n");
-            break;
-        }
-    }
-
-    if (lastused) {
-        LOG(L_INFO,
-            "osp: report orig setup for call_id '%.*s' transaction_id '%llu'\n",
-            lastused->callidsize,
-            lastused->callid,
-            lastused->transid);
-        errorcode = ospReportUsageFromDestination(transaction, lastused);
-    } else {
-        /* If a Toolkit transaction handle was created, but we did not find
-         * any destinations to report, we need to release the handle. Otherwise,
-         * the ospReportUsageFromDestination will release it.
-         */
-        OSPPTransactionDelete(transaction);
-    }
-}
-
-/*
- * Report terminate call setup usage
- */
-void ospReportTermSetupUsage(void)
-{
-    osp_dest* dest = NULL;
-    OSPTTRANHANDLE transaction = -1;
-    int errorcode;
-
-    LOG(L_DBG, "osp: ospReportTermSetupUsage\n");
-
-    if ((dest = ospGetTermDestination())) {
-        if (dest->reported == 0) {
-            dest->reported = 1;
-            LOG(L_INFO,
-                "osp: report term setup for call_id '%.*s' transaction_id '%llu'\n",
-                dest->callidsize,
-                dest->callid,
-                dest->transid);
-            errorcode = OSPPTransactionNew(_osp_provider, &transaction);
-            errorcode = ospBuildUsageFromDestination(transaction, dest, 0);
-            errorcode = ospReportUsageFromDestination(transaction, dest);
-        } else {
-            LOG(L_DBG, "osp: term setup already reported\n");
-        }
-    } else {
-        LOG(L_ERR, "osp: ERROR: without term setup to report\n");
-    }
-}

+ 0 - 64
modules_s/osp/usage.h

@@ -1,64 +0,0 @@
-/*
- * ser osp module. 
- *
- * This module enables ser to communicate with an Open Settlement 
- * Protocol (OSP) server.  The Open Settlement Protocol is an ETSI 
- * defined standard for Inter-Domain VoIP pricing, authorization
- * and usage exchange.  The technical specifications for OSP 
- * (ETSI TS 101 321 V4.1.1) are available at www.etsi.org.
- *
- * Uli Abend was the original contributor to this module.
- * 
- * Copyright (C) 2001-2005 Fhg Fokus
- *
- * This file is part of ser, a free SIP server.
- *
- * ser is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * For a license to use the ser software under conditions
- * other than those described here, or to purchase support for this
- * software, please contact iptel.org by e-mail at the following addresses:
- *    [email protected]
- *
- * ser is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _OSP_MOD_USAGE_H_
-#define _OSP_MOD_USAGE_H_
-
-#include <osp/osp.h>
-#include "../../parser/msg_parser.h"
-
-/* This module reports originating and terminating call set up and duration usage
- * for OSP transactions.
- *
- * Call set-up usage is reported based on the osp_dest structures stored as AVPs.
- * It includes OSP transaction id, response codes, start time, alert time,
- * connect time, etc.
- *
- * Duration usage is reported based on the OSP cooky recorded into the route set
- * (using add_rr_param) after requesting routing/authorization on the originating
- * side, and validating authorization on the terminating side.  It include 
- * OSP transaction id, duration, stop time, etc.
- * 
- * Actual conversation duration maybe calculated using connect time (from the call
- * set up usage) and stop time (from the duration usage). 
- */
-void ospRecordOrigTransaction(struct sip_msg* msg, unsigned long long transid, char* uac, char* from, char* to, time_t authtime, unsigned destinationCount);
-void ospRecordTermTransaction(struct sip_msg* msg, unsigned long long transid, char* uac, char* from, char* to, time_t authtime);
-void ospReportOrigSetupUsage(void);
-void ospReportTermSetupUsage(void);
-int  ospReportUsage(struct sip_msg* msg, char* ignore1, char* ignore2);
-
-#endif /* _OSP_MOD_USAGE_H_ */
-