### Start OpenSIPS with LD_LIBRARY_PATH (Example) Source: https://github.com/vanminh2018/opensips-docs/blob/main/snmpstats/README.txt This is an example command demonstrating how to start OpenSIPS while setting the LD_LIBRARY_PATH environment variable to include the directory containing the NetSNMP libraries (/usr/local/lib in this case). Adjust the path and the OpenSIPS startup command as needed for your system. ```Shell LD_LIBRARY_PATH=/usr/local/lib /etc/init.d/opensips start ``` -------------------------------- ### Example HTTP Queries with Variables (HTTP) Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_http/README.txt Provides examples of HTTP GET and POST queries using various variables (`k`, `v`, `c`, `query_type`) to specify database operations via the `db_http` module. The GET example queries the `/version/` table, while the POST example demonstrates an `insert` operation on the `/active_watchers` table. ```HTTP GET /version/?k=table_name&v=xcap&c=table_version HTTP/1.1 ... POST /active_watchers HTTP/1.1 k=id&v=100&query_type=insert ``` -------------------------------- ### Starting RTPEngine Call Recording - OpenSIPS Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Calls the rtpengine_start_recording function without parameters. This signals the RTPEngine proxy to begin recording the RTP stream for the current call. ```OpenSIPS Script rtpengine_start_recording(); ``` -------------------------------- ### Example Reload Report JSON Output Source: https://github.com/vanminh2018/opensips-docs/blob/main/dispatcher/README.txt Example JSON output showing the structure and content of reload reports provided by the dispatcher module. It includes timestamps, dates, and log messages related to database loading. ```json { "Name": "default", "Reports": [ { "Timestamp": 1652373212, "Date": "Thu May 12 19:33:32 2022", "Log": "starting DB data loading" }, { "Timestamp": 1652373212, "Date": "Thu May 12 19:33:32 2022", "Log": "DB data loading successfully completed" }, { "Timestamp": 1652373212, "Date": "Thu May 12 19:33:32 2022", "Log": "2 destinations loaded (0 discarded)" } ] } ``` -------------------------------- ### Starting RTP Media Forwarding (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt This function starts forwarding media streams via rtpengine. It can optionally take a `from-tag` parameter to forward only specific streams. If no tag is provided, all media streams are forwarded. It can be used from any route. ```OpenSIPS Script rtpengine_start_forwarding(); ``` -------------------------------- ### Example Destination Switching Report JSON Output Source: https://github.com/vanminh2018/opensips-docs/blob/main/dispatcher/README.txt Example JSON output illustrating the structure of destination switching reports. These reports detail state changes for destinations, including the reason for the change, and are provided via a separate identifier. ```json { "Name": "default;events", "Reports": [ { "Timestamp": 1652373308, "Date": "Thu May 12 19:35:08 2022", "Log": "DESTINATION , set 1 switched to [inactive] due to negative probing reply\n" }, { "Timestamp": 1652373308, "Date": "Thu May 12 19:35:08 2022", "Log": "DESTINATION , set 1 switched to [inactive] due to negative probing reply\n" } ] } ``` -------------------------------- ### Installing OpenSIPS Default Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt This command initiates the default installation of OpenSIPS from the source root folder. By default, OpenSIPS will be installed in the `/` directory. ```Shell make install ``` -------------------------------- ### Installing LaunchDarkly C Server SDK (Shared Lib) - Shell Source: https://github.com/vanminh2018/opensips-docs/blob/main/launch_darkly/README.txt Provides shell commands to clone, configure, and install the LaunchDarkly C Server SDK as a shared library, which is required for the OpenSIPS module dependency. ```Shell $ git clone https://github.com/launchdarkly/c-server-sdk.git $ cd c-server-sdk $ cmake -DBUILD_SHARED_LIBS=On -DBUILD_TESTING=OFF . $ sudo make install ``` -------------------------------- ### Example Capability Status JSON Source: https://github.com/vanminh2018/opensips-docs/blob/main/clusterer/README.txt Example JSON structure showing the format of a capability status entry, indicating the readiness, sync status (using numerical codes), and a detailed description. ```JSON { "Name": "cap:dialog-dlg-repl", "Readiness": true, "Status": 1, "Details": "synced" } ``` -------------------------------- ### Example Basic HTTP GET Query (HTTP) Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_http/README.txt Demonstrates a basic HTTP GET request format expected by the `db_http` module for querying data. This example queries the `/presentity/` endpoint, requesting specific columns (`username`, `domain`, `event`, `expires`) using the `c` variable. ```HTTP GET /presentity/?c=username,domain,event,expires HTTP/1.1 ``` -------------------------------- ### Example Capability Reports JSON Source: https://github.com/vanminh2018/opensips-docs/blob/main/clusterer/README.txt Example JSON structure showing the format of capability report entries, detailing the main stages of the sync process with timestamps, dates, and log messages. ```JSON { "Name": "cap:dialog-dlg-repl", "Reports": [ { "Timestamp": 1656966903, "Date": "Mon Jul 4 23:35:03 2022", "Log": "Sync requested" }, { "Timestamp": 1656966904, "Date": "Mon Jul 4 23:35:04 2022", "Log": "Sync started from node [1]" }, { "Timestamp": 1656966906, "Date": "Mon Jul 4 23:35:06 2022", "Log": "Sync completed, received [10000] chunks" } ] } ``` -------------------------------- ### Using rtpengine_offer for Transcoding (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt This example shows how to use the rtpengine_offer function in the context of transcoding. Although the function call itself is simple, the surrounding comments indicate the intention is to manipulate codecs (e.g., mask PCMA for one side, strip opus for another) to achieve transcoding between different endpoints. ```OpenSIPS # Goal: make A-side talk PCMA and B-side talk opus # * do not present PCMA to B-side: codec-mask-PCMA, but use it on A-side # * do not use opus for A-side: codec-strip-opus rtpengine_offer($var(rtpengine_flags)); ``` -------------------------------- ### Install OpenSIPS Standard Procedure Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_berkeley/README.txt Executes the standard OpenSIPS build and installation process using the default Makefile configuration, assuming 'db_berkeley' is not in the 'excluded_modules' list. ```Shell make all; make install ``` -------------------------------- ### Example drouting Partition Reload Status Report (JSON) Source: https://github.com/vanminh2018/opensips-docs/blob/main/drouting/README.txt This JSON object shows an example of the status report provided by the [partition_name] identifier within the drouting Status/Report group. It illustrates the logs generated during a successful data reload operation for a routing partition, including the start, completion, and summary of loaded entities. ```JSON { "Name": "Default", "Reports": [ { "Timestamp": 1652353940, "Date": "Thu May 12 14:12:20 2022", "Log": "starting DB data loading" }, { "Timestamp": 1652353940, "Date": "Thu May 12 14:12:20 2022", "Log": "DB data loading successfully completed" }, { "Timestamp": 1652353940, "Date": "Thu May 12 14:12:20 2022", "Log": "2 gateways loaded (0 discarded), 2 carriers load\ned (0 discarded), 1 rules loaded (0 discarded)" } ] } ``` -------------------------------- ### Example Output cache_fetch_chunk MI JSON Source: https://github.com/vanminh2018/opensips-docs/blob/main/cachedb_local/README.txt An example of the JSON output returned by the cache_fetch_chunk Management Interface command, showing a list of matching keys and their values. ```JSON { "keys": [ { "name": "keyprefix_1", "value": "key 1 data here" }, { "name": "keyprefix_2", "value": "key 2 data here" } ] } ``` -------------------------------- ### Configuring OpenSIPS Install Path via Menuconfig Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt This command launches the OpenSIPS menuconfig tool, allowing users to interactively configure various installation parameters, such as the custom installation prefix. It's a prerequisite for changing the default installation directory. ```Shell make menuconfig ``` -------------------------------- ### Compile and Install OpenSIPS with db_sqlite Module (Shell) Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_sqlite/README.txt This command-line sequence compiles OpenSIPS including the `db_sqlite` module and then installs it. It provides an alternative installation method to manually editing the Makefile. Execute these commands from the root of the OpenSIPS source directory. ```Shell make all include_modules="db_sqlite"; make install include_modules="db_sqlite" ``` -------------------------------- ### Calling example Function in OpenSIPS Script Source: https://github.com/vanminh2018/opensips-docs/blob/main/example/README.txt Invokes the 'example' function from the 'example' module. This function logs a message indicating it has been called and can be used from any route in the OpenSIPS script. ```OpenSIPS Script example(); ``` -------------------------------- ### Resuming Music on Hold with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt An example demonstrating how to use rtpengine_play_media with the 'start-pos' flag and rtpengine_stop_media with the 'last_frame_pos' parameter to resume music on hold from the last played position. Note the potential syntax error in the original code's dialog variable assignment. ```OpenSIPS Script if (is_method("INVITE") && has_totag()) { if (is_audio_on_hold()) { $dlg_val(on_hold = "1"; rtpengine_play_media("from-tag=$tt start-pos=$avp(last_frame_pos) file=/path/to/moh_file.wav"); } else if ($dlg_val(on_hold) == "1") { rtpengine_stop_media("from-tag=$tt", , $avp(last_frame_pos)); $dlg_val(on_hold = "0"); } } rtpengine_stop_media(); ``` -------------------------------- ### Initializing Data with OpenSIPS startup_route Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Script-Routes-3-6.txt The `startup_route` is executed once when OpenSIPS starts, before SIP message processing. It's ideal for initial setup like loading data into cache using `avp_db_query` and `cache_store` to optimize subsequent operations. This route does not process SIP messages, so functions called here should not depend on message context. ```OpenSIPS Script startup_route { avp_db_query("select gwlist where ruleid==1",$avp(i:100)); cache_store("local", "rule1", "$avp(i:100)"); } ``` -------------------------------- ### Start OpenSIPS Dynamic Trace by Users - Shell Source: https://github.com/vanminh2018/opensips-docs/blob/main/tracer/README.txt Starts a dynamic tracing instance filtered by caller and callee usernames, sending output to a HEP destination using the `opensips-cli` tool. ```Shell opensips-cli -x mi trace_start id=alice_bob uri=hep:10.0.0.1:9060 filter=caller=Alice filter=caller=Bob ``` -------------------------------- ### Unblocking Media Stream with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Simple example showing the basic usage of the rtpengine_unblock_media function to resume a previously blocked RTP media stream. The direction can be controlled by flags like 'from-tag'. ```OpenSIPS Script rtpengine_unblock_media(); ``` -------------------------------- ### Running Menuconfig from OpenSIPS Installation Path (Shell) Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Generating-Configs-3-6.txt After OpenSIPS has been installed, this command allows users to run the menuconfig tool directly from the installation directory. It executes the 'osipsconfig' binary located in the sbin subdirectory of the OpenSIPS installation path. ```Shell [install_path]/sbin/osipsconfig ``` -------------------------------- ### Installing OpenSIPS to Custom Path Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt After configuring a custom installation path using `make menuconfig` and saving the changes, this command will install OpenSIPS to the newly specified directory instead of the default location. This is useful for deploying multiple OpenSIPS instances. ```Shell make install ``` -------------------------------- ### RabbitMQ Socket String Format Examples Source: https://github.com/vanminh2018/opensips-docs/blob/main/event_rabbitmq/README.txt These examples illustrate different formats for specifying RabbitMQ server connection strings in OpenSIPS, including basic authentication, simplified host/path, and options for TLS connections. ```Configuration rabbitmq:guest:guest@127.0.0.1:5672/pike ``` ```Configuration rabbitmq:127.0.0.1/pike ``` ```Configuration rabbitmq:127.0.0.1/tls_domain=rmq?pike ``` -------------------------------- ### Starting RTP Recording with Default Parameters in OpenSIPS Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpproxy/README.txt This snippet shows the simplest usage of the rtpproxy_start_recording function in OpenSIPS script. Calling it without any parameters instructs RTPproxy to start recording the current RTP session using default settings, typically saving to a file in the configured recording directory. ```OpenSIPS Script rtpproxy_start_recording(); ``` -------------------------------- ### Execute OpenSIPS Installation as Root Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_berkeley/README.txt Runs the installation target of the OpenSIPS Makefile, typically executed as the root user from the main source directory to install binaries and files into the system path. ```Shell make install ``` -------------------------------- ### Cloning OpenSIPS Conformance Tests Repository (Git) Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Conformance-Tests-3-6.txt This command initializes the setup for OpenSIPS conformance tests by cloning the entire `sipssert-opensips-tests` repository from GitHub. It fetches all branches and history, preparing the environment for testing. ```Shell git clone git@github.com:OpenSIPS/sipssert-opensips-tests.git ``` -------------------------------- ### Install OpenSIPS with db_berkeley Module via Command Line Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_berkeley/README.txt Builds and installs OpenSIPS specifically including the 'db_berkeley' module by overriding the default excluded modules list via command line arguments during the make process. ```Shell make all include_modules="db_berkeley"; make install include_modules="db_berkeley" ``` -------------------------------- ### Start OpenSIPS Dynamic Trace by IP - Shell Source: https://github.com/vanminh2018/opensips-docs/blob/main/tracer/README.txt Starts a dynamic tracing instance filtered by source IP address, sending output to a HEP destination using the `opensips-cli` tool. ```Shell opensips-cli -x mi trace_start id=ip_filter uri=hep:10.0.0.1:9060 filter=ip=127.0.0.1 ``` -------------------------------- ### Carrierroute Module Configuration File Example Source: https://github.com/vanminh2018/opensips-docs/blob/main/carrierroute/README.txt Provides an example of the carrierroute module's configuration file format, defining domains, prefixes, and targets with properties like max_targets, prob, hash_index, status, and comment. ```OpenSIPS Module Configuration domain proxy { prefix 49 { max_targets = 2 target proxy1.localdomain { prob = 0.500000 hash_index = 1 status = 1 comment = "test target 1" } target proxy2.localdomain { prob = 0.500000 hash_index = 2 status = 1 comment = "test target 2" } } } domain register { prefix NULL { max_targets = 2 target register1.localdomain { prob = 0.500000 hash_index = 1 status = 1 comment = "test target 1" } target register2.localdomain { prob = 0.500000 hash_index = 2 status = 1 comment = "test target 2" } } } ``` -------------------------------- ### Installing ncurses Development Library (Debian) Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt This command installs the 'libncurses5-dev' package on Debian-based systems. This library is a prerequisite for running the 'menuconfig' tool, which is used to configure OpenSIPS compile-time options. ```Shell apt-get install libncurses5-dev ``` -------------------------------- ### Example Regex File Format Source: https://github.com/vanminh2018/opensips-docs/blob/main/regex/README.txt This snippet shows the expected format for the regex file used by the regex module, particularly for functions like pcre_match_group. It includes group markers (e.g., [0]), comments (lines starting with #), and individual regular expressions on separate lines. ```Regex File Format ### List of User-Agents publishing presence status [0] # Softphones ^Twinkle/1 ^X-Lite ^eyeBeam ^Bria ^SIP Communicator ^Linphone # Deskphones ^Snom # Others ^SIPp ^PJSUA ### Blacklisted source IP's [1] ^190\.232\.250\.226$ ^122\.5\.27\.125$ ^86\.92\.112\. ``` -------------------------------- ### Calling example_str Function in OpenSIPS Script Source: https://github.com/vanminh2018/opensips-docs/blob/main/example/README.txt Invokes the 'example_str' function from the 'example' module with an optional string parameter. If a parameter is provided, it is logged; otherwise, the value of the 'default_str' parameter is used. This function can be used from any route. ```OpenSIPS Script example_str("test"); ``` -------------------------------- ### Example db_berkeley Table Column and Key Metadata Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_berkeley/README.txt Shows example metadata rows ('METADATA_COLUMNS' and 'METADATA_KEY') from a db_berkeley table, defining column names, types, and which column(s) constitute the primary key for data interpretation. ```Text METADATA_COLUMNS table_name(str) table_version(int) METADATA_KEY 0 ``` -------------------------------- ### Example snmptable Output Header Source: https://github.com/vanminh2018/opensips-docs/blob/main/snmpstats/README.txt This is an example of the header row displayed by the snmptable command for the openserSIPRegUserTable. It lists the columns included in the table output, starting with the index column. ```SNMP Output index openserSIPUserUri openserSIPUserAuthenticationFailures ``` -------------------------------- ### Accessing RTP Statistics using $rtpstat (OpenSIPS Script) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt This snippet demonstrates how to retrieve various RTP statistics such as average MOS, minimum MOS, and the time of minimum MOS using the `$rtpstat` variable. It shows examples for the entire call and specific call legs (`$ft` for caller, `$tt` for callee). ```OpenSIPS Script xlog("Average MOS of the entire call is $rtpstat(MOS-average)\r\n"); xlog("Average MOS of caller is $(rtpstat(MOS-average)[$ft])\r\n"); xlog("Average MOS of callee is $(rtpstat(MOS-average)[$tt])\r\n"); xlog("Min MOS of caller is $(rtpstat(MOS-min)[$ft]) reported at $(rt pstat(MOS-min-at)[$ft])\r\n"); ``` -------------------------------- ### Getting Shared Variables with opensips-cli Source: https://github.com/vanminh2018/opensips-docs/blob/main/cfgutils/README.txt Demonstrates how to use the `shv_get` Management Interface command via `opensips-cli`. The first example retrieves the shared variable named 'debug', while the second example retrieves all shared variables. ```opensips-cli $ opensips-cli -x mi shv_get debug $ opensips-cli -x mi shv_get ``` -------------------------------- ### Sample OpenSIPS Dispatcher Configuration Source: https://github.com/vanminh2018/opensips-docs/blob/main/dispatcher/README.txt A sample OpenSIPS configuration file demonstrating the basic usage of the dispatcher module. It includes socket binding, worker settings, DNS options, module loading paths, and specific module loading directives. ```opensips-config # # sample config file for dispatcher module # socket= udp:*:5060 udp_workers = 2 check_via = off # (cmd. line: -v) dns = off # (cmd. line: -r) rev_dns = off # (cmd. line: -R) # for more info: opensips -h # ------------------ module loading ---------------------------------- mpath = "/usr/lib/x86_64-linux-gnu/opensips/modules" loadmodule "maxfwd.so" loadmodule "signaling.so" loadmodule "sl.so" loadmodule "tm.so" loadmodule "db_mysql.so" loadmodule "dispatcher.so" loadmodule "proto_udp.so" ``` -------------------------------- ### Starting Load Balancing Session with lb_start (OpenSIPS Script) Source: https://github.com/vanminh2018/opensips-docs/blob/main/load_balancer/README.txt Demonstrates the usage of the lb_start function. It attempts to start a load balancing session for group 1, requiring "transcoding" and "conference" resources. If successful, it logs the selected destination URI ($du), relays the call using t_relay, and exits the script. ```OpenSIPS Script if (lb_start(1,"trascoding;conference")) { # dst URI points to the new destination xlog("sending call to $du\n"); t_relay(); exit; } ``` -------------------------------- ### Install Runtime Dependencies for cachedb_mongodb (Debian/Ubuntu) Source: https://github.com/vanminh2018/opensips-docs/blob/main/cachedb_mongodb/README.txt This snippet provides the shell commands required to install the necessary runtime libraries (libjson-c and libmongoc) for the cachedb_mongodb module on Debian or Ubuntu systems using apt-get. ```Shell # Debian / Ubuntu sudo apt-get install libjson-c2 libmongoc-1.0 ``` -------------------------------- ### Example clusterer Database Table Content Source: https://github.com/vanminh2018/opensips-docs/blob/main/clusterer/README.txt Example content for the clusterer database table, showing configuration for two OpenSIPS nodes (Node A and Node B) including cluster ID, node ID, BIN URL, state, ping retries, priority, and description. ```Table +----+------------+---------+----------------------+-------+---------------------+ | id | cluster_id | node_id | url | state | no_ping_retries | +----+------------+---------+----------------------+-------+---------------------+ | 10 | 1 | 1 | bin:192.168.0.5:5566 | 1 | 3 | | 20 | 1 | 2 | bin:192.168.0.6:5566 | 1 | 3 | +----+------------+---------+----------------------+-------+---------------------+ +----------+----------+-------+-------------+ | priority | sip_addr | flags | description | +----------+----------+-------+-------------+ | 50 | NULL | NULL | Node A | | 50 | NULL | NULL | Node B | +----------+----------+-------+-------------+ ``` -------------------------------- ### Basic OpenSIPS Configuration with db_text Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_text/README.txt This is a simple OpenSIPS configuration file demonstrating how to integrate the db_text module, including global parameters, module loading (db_text, sl, tm, rr, maxfwd, usrloc, registrar, textops, mi_fifo, auth, auth_db), and basic settings for a quick-start setup. ```OpenSIPS Config # # simple quick-start config script with dbtext # # ----------- global configuration parameters ------------------------ #debug_mode=yes udp_workers=4 check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) socket=udp:10.100.100.1:5060 # ------------------ module loading ---------------------------------- # use dbtext database loadmodule "modules/dbtext/dbtext.so" loadmodule "modules/sl/sl.so" loadmodule "modules/tm/tm.so" loadmodule "modules/rr/rr.so" loadmodule "modules/maxfwd/maxfwd.so" loadmodule "modules/usrloc/usrloc.so" loadmodule "modules/registrar/registrar.so" loadmodule "modules/textops/textops.so" loadmodule "modules/textops/mi_fifo.so" # modules for digest authentication loadmodule "modules/auth/auth.so" loadmodule "modules/auth_db/auth_db.so" ``` -------------------------------- ### Example JSONRPC Get Statistics Request via MI Datagram Source: https://github.com/vanminh2018/opensips-docs/blob/main/mi_datagram/README.txt Provides an example of a JSONRPC request message formatted for the MI Datagram interface. This specific request uses the 'get_statistics' method to retrieve statistics for the 'dialog:' and 'tm:' categories. ```JSON {"jsonrpc":"2.0","method":"get_statistics","id":"1065","params":[["dialog:","tm:"]]} ``` -------------------------------- ### Setting OpenSIPS LDAP Client Key File Path Source: https://github.com/vanminh2018/opensips-docs/blob/main/ldap/README.txt Example configuring the `ldap_key_file` parameter, specifying the full path to the client key file required for using StartTLS. ```OpenSIPS Config ldap_key_file = "/usr/local/mykey.pem" ``` -------------------------------- ### Example Dialog-Info XML with Multiple Dialogs Source: https://github.com/vanminh2018/opensips-docs/blob/main/pua_dialoginfo/README.txt Provides a complete example of a dialog-info XML document containing two elements. This demonstrates how an entity with multiple ongoing calls can be represented, showing both a 'confirmed' and an 'early' state dialog, which can be aggregated by the presence_dialoginfo module. ```XML confirmed early ``` -------------------------------- ### Forking All Media from Existing Call using B2B Module (OpenSIPS Script) Source: https://github.com/vanminh2018/opensips-docs/blob/main/media_exchange/README.txt This example shows how to use the `media_fork_from_call` function in the initial INVITE route to start streaming all media streams from an existing proxied call, identified by a Call-ID retrieved from a custom header (`X-CallID`). It checks for an initial INVITE and the presence of the Call-ID header. ```OpenSIPS Script if (!has_totag() && is_method("INVITE") && $hdr(X-CallID) != NULL) media_fork_from_call($hdr(X-CallID)); ``` -------------------------------- ### Counting Destinations with ds_count (OpenSIPS Scripting) Source: https://github.com/vanminh2018/opensips-docs/blob/main/dispatcher/README.txt These examples show how to use the ds_count function to count destinations within a dispatcher set based on their state. The first example counts active ('a') destinations in set 1, storing the result in $avp(result). The second example uses AVPs for set, state filter ('ip' for inactive/probing), result variable, and partition name. ```OpenSIPS Scripting if (ds_count(1, "a", $avp(result))) { ... } ``` ```OpenSIPS Scripting if (ds_count($avp(set), "ip", $avp(result), $avp(partition))) { ... } ``` -------------------------------- ### Sample OpenSIPS Configuration with event_rabbitmq Source: https://github.com/vanminh2018/opensips-docs/blob/main/event_rabbitmq/README.txt This comprehensive example demonstrates loading the `event_rabbitmq` module, subscribing to the `E_SIP_MESSAGE` event, and integrating RabbitMQ publishing logic within the main `route` block of an OpenSIPS configuration script. ```OpenSIPS Script loadmodule "signaling.so" loadmodule "sl.so" loadmodule "tm.so" loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "usrloc.so" loadmodule "registrar.so" loadmodule "textops.so" loadmodule "uri.so" loadmodule "acc.so" loadmodule "event_rabbitmq.so" startup_route { if (!subscribe_event("E_SIP_MESSAGE", "rabbitmq:127.0.0.1/sipmsg ")) { xlog("L_ERR","cannot the RabbitMQ server to the E_SIP_ME SSAGE event\\n"); } } route{ if (!mf_process_maxfwd_header(10)) { sl_send_reply(483,"Too Many Hops"); exit; } if (has_totag()) { if (loose_route()) { if (is_method("INVITE")) { record_route(); } route(1); } else { if ( is_method("ACK") ) { if ( t_check_trans() ) { t_relay(); exit; } else { exit; } } sl_send_reply(404,"Not here"); } exit; } if (is_method("CANCEL")) { if (t_check_trans()) t_relay(); exit; } t_check_trans(); if (loose_route()) { xlog("L_ERR", "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"); if (!is_method("ACK")) sl_send_reply(403,"Preload Route denied"); exit; } if (!is_method("REGISTER|MESSAGE")) record_route(); if (!is_myself("$rd")) { append_hf("P-hint: outbound\\r\\n"); route(1); } if (is_method("PUBLISH")) { sl_send_reply(503, "Service Unavailable"); exit; } if (is_method("REGISTER")) { ``` -------------------------------- ### Starting CGRateS Accounting after Authentication - OpenSIPS Source: https://github.com/vanminh2018/opensips-docs/blob/main/cgrates/README.txt This example shows how to call the 'cgrates_acc' function to start a CGRateS accounting session. It is typically called after a successful 'cgrates_auth' check and includes flags to generate a CDR for both successful and missed calls, using the From user ($fU) and Request URI user ($rU) for account and destination. ```OpenSIPS if (cgrates_auth($fU, $rU)) cgrates_acc("cdr|missed", $fU, $rU); ``` -------------------------------- ### Running All OpenSIPS Conformance Tests (SIPssert) Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Conformance-Tests-3-6.txt Execute this command within the tests directory to run all available OpenSIPS conformance test sets using the `sipssert` framework. It initiates the full test suite with default configurations, validating OpenSIPS behavior across various scenarios. ```Shell sipssert * ``` -------------------------------- ### Running Local DynamoDB Server Source: https://github.com/vanminh2018/opensips-docs/blob/main/cachedb_dynamodb/README.txt Command to start a local instance of DynamoDB for testing purposes, specifying the library path and enabling the shared database option. ```Java Command java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb ``` -------------------------------- ### Handling SDP with rtpengine_offer and rtpengine_answer in OpenSIPS Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Demonstrates the basic usage of `rtpengine_offer` and `rtpengine_answer` functions within OpenSIPS `route` and `onreply_route` blocks. It shows how to call `rtpengine_offer` for INVITE requests with SDP, set up reply routes using `t_on_reply`, and call `rtpengine_answer` for ACK requests with SDP or in reply routes when an SDP body is present. ```OpenSIPS Script route { ... if (is_method("INVITE")) { if (has_body("application/sdp")) { if (rtpengine_offer()) t_on_reply("1"); } else { t_on_reply("2"); } } if (is_method("ACK") && has_body("application/sdp")) rtpengine_answer(); ... } ``` ```OpenSIPS Script onreply_route[1] { ... if (has_body("application/sdp")) rtpengine_answer(); ... } ``` ```OpenSIPS Script onreply_route[2] { ... if (has_body("application/sdp")) rtpengine_offer(); ... } ``` -------------------------------- ### Using rls_handle_subscribe Function (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rls/README.txt Demonstrates how to use the rls_handle_subscribe function in the REQUEST_ROUTE to process resource list Subscribe messages, showing examples for both collocated presence/RLS and RLS-only setups. ```OpenSIPS For presence and rls on the same machine: modparam(rls, "to_presence_code", 10) if(is_method("SUBSCRIBE")) { $var(ret_code)= rls_handle_subscribe(); if($var(ret_code)== 10) handle_subscribe(); t_release(); } For rls only: if(is_method("SUBSCRIBE")) { rls_handle_subscribe(); t_release(); } ``` -------------------------------- ### Configuring OpenSIPS Compile Options Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt This command launches the curses-based 'menuconfig' tool, which allows users to interactively configure various compile-time options for OpenSIPS, such as enabling TLS or memory debugging. It must be run from the OpenSIPS sources root folder after installing the ncurses development library. ```Shell make menuconfig ``` -------------------------------- ### Example db_berkeley Table Metadata Settings Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_berkeley/README.txt Shows example default metadata settings for a db_berkeley table, indicating read-only status and logging flags. These settings can be modified per table. ```Text METADATA_READONLY 0 METADATA_LOGFLAGS 0 ``` -------------------------------- ### Example OpenSIPS LDAP Configuration File Source: https://github.com/vanminh2018/opensips-docs/blob/main/ldap/README.txt A comprehensive example demonstrating the configuration of two distinct LDAP sessions (`sipaccounts` and `campus`) within an OpenSIPS configuration file, showcasing various parameters including server URLs, authentication, timeouts, and TLS settings. ```OpenSIPS Config # LDAP session "sipaccounts": # # - using LDAPv3 (default) # - two redundant LDAP servers # [sipaccounts] ldap_server_url = "ldap://h350-1.example.com, ldap://h350-2.example.com" ldap_bind_dn = "cn=sip_proxy,ou=accounts,dc=example,dc=com" ldap_bind_password = "pwd" ldap_network_timeout = 500 ldap_client_bind_timeout = 500 #using StartTLS ldap_ca_cert_file = "/ldap/path/to/ca/certificate.pem" ldap_cert_file = "/ldap/path/to/certificate.pem" ldap_key_file = "/ldap/path/to/key/file.pem" ldap_require_certificate = "NEVER" # LDAP session "campus": # # - using LDAPv2 # - anonymous bind ``` -------------------------------- ### Set mi_html http_method parameter (OpenSIPS Config) Source: https://github.com/vanminh2018/opensips-docs/blob/main/mi_html/README.txt Specifies the HTTP request method to be used by mi_html. 0 for GET, 1 for POST. This example sets it to 1 (POST). ```OpenSIPS Config modparam("mi_html", "http_method", 1) ``` -------------------------------- ### Retrieving OpenSIPS Startup Arguments (Shell) Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Interface-CoreMI-3-6.txt This command returns the full list of arguments used when OpenSIPS was started. The first argument is typically the name of the executable binary. It takes no arguments and outputs an array of strings. ```Shell # opensips-cli -x mi arg ``` ```JSON [ "./opensips", "-f", "/etc/openser/test.cfg" ] ``` -------------------------------- ### Sample OpenSIPS XMPP Gateway Configuration Source: https://github.com/vanminh2018/opensips-docs/blob/main/xmpp/README.txt A basic configuration script for setting up a standalone OpenSIPS instance to function as a SIP-to-XMPP gateway. It includes global parameters, module loading (including xmpp), module-specific parameters, and placeholders for routing logic. ```OpenSIPS Configuration # # simple quick-start config script for XMPP GW # # make sure in your main SIP server that you send # only the adequate SIP MESSAGES to XMPP GW # # # ----------- global configuration parameters ------------------------ log_level=3 # debug level (cmd line: -dddddddddd) stderror_enabled=no syslog_enabled=yes /* Uncomment these line to enter debugging mode */ #debug_mode=yes check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) udp_workers=4 socket=udp:10.10.10.10:5076 alias=sip-xmpp.opensips.org # ------------------ module loading ---------------------------------- mpath="/usr/local/opensips/lib/opensips/modules/" loadmodule "sl.so" loadmodule "tm.so" loadmodule "rr.so" loadmodule "maxfwd.so" loadmodule "textops.so" loadmodule "mi_fifo.so" # XMPP loadmodule "xmpp.so" modparam("xmpp", "xmpp_domain", "xmpp-sip.opensips.org") modparam("xmpp", "xmpp_host", "xmpp.opensips.org") #modparam("xmpp", "backend", "server") modparam("xmpp", "backend", "component") # ----------------- setting module-specific parameters --------------- # -- mi_fifo params -- modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo_xmpp") # ------------------------- request routing logic ------------------- ``` -------------------------------- ### Example node_states Report JSON Source: https://github.com/vanminh2018/opensips-docs/blob/main/clusterer/README.txt Example JSON structure showing the format of a node_states status/report entry, including timestamp, date, and log message detailing the node's availability state change. ```JSON { "Name": "node_states", "Reports": [ { "Timestamp": 1656489246, "Date": "Wed Jun 29 10:54:06 2022", "Log": "Node [2], cluster [1] is UP" }, { "Timestamp": 1656489261, "Date": "Wed Jun 29 10:54:21 2022", "Log": "Node [2], cluster [1] is DOWN" } ] } ``` -------------------------------- ### Calling example_int Function in OpenSIPS Script Source: https://github.com/vanminh2018/opensips-docs/blob/main/example/README.txt Invokes the 'example_int' function from the 'example' module with an optional integer parameter. If a parameter is provided, it is logged; otherwise, the value of the 'default_int' parameter is used. This function can be used from any route. ```OpenSIPS Script example_int(10); ``` -------------------------------- ### Stopping Ringback Tone with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Illustrates how to stop media playback initiated by rtpengine_play_media. This example stops the ringback tone when a 200 OK response is received for an INVITE. ```OpenSIPS Script if (is_method("INVITE") && $rs == 200) rtpengine_stop_media(); ``` -------------------------------- ### Example Usage of dp_can_connect (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/domainpolicy/README.txt Illustrates how to call the `dp_can_connect` function within an OpenSIPS script and process its return value. The example demonstrates handling different outcomes (-2, -1, 1, 2) by logging messages, sending SIP replies, printing AVPs, applying policy, or relaying the request. ```OpenSIPS Script dp_can_connect(); switch(retcode) { case -2: xlog("L_INFO","Errors during the DP evaluation\n"); sl_send_reply(404, "We can't connect you."); break; case -1: xlog("L_INFO","We can't connect to that domain\n"); sl_send_reply(404, "We can't connect you."); break; case 1: xlog("L_INFO","We found matching policy records\n"); avp_print(); dp_apply_policy(); t_relay(); break; case 2: xlog("L_INFO","No DP records found\n"); t_relay(); break; } ``` -------------------------------- ### Retrieving OpenSIPS Message Type String Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Script-CoreVar-3-6.txt This example shows how to get the string representation of the current SIP message type (e.g., 'request' or 'reply') using the `$msg.type` variable and log it. ```OpenSIPS Script xlog("---- this message is a SIP $msg.type \n"); ``` -------------------------------- ### Preparing Metadata and Calling rtpengine_offer (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt This snippet demonstrates how to populate JSON variables with call details and concatenate them into a variable used for RTPengine flags, specifically for passing metadata. It then calls the rtpengine_offer function with these flags. ```OpenSIPS $json(recording_keys/callId) = $ci; $json(recording_keys/fromUser) = $dlg_val(recording_from_user); $json(recording_keys/fromDomain) = $dlg_val(recording_from_domain); $json(recording_keys/fromTag) = $dlg_val(recording_from_tag); $json(recording_keys/toUser) = $dlg_val(recording_to_user); $json(recording_keys/toDomain) = $dlg_val(recording_to_domain); $var(rtpengine_flags) = $var(rtpengine_flags) + " metadata=" + $(json(recording_keys){s.encode.hexa}); rtpengine_offer($var(rtpengine_flags)); ``` -------------------------------- ### Using Benchmark Module C API Source: https://github.com/vanminh2018/opensips-docs/blob/main/benchmark/README.txt Shows how to integrate the benchmark module's internal C API into another OpenSIPS module. It includes loading the API, registering a timer, starting it, performing an action, and logging the duration using the API functions. ```C #include "../benchmark/benchmark.h" ... struct bm_binds bmb; ... ... /* load the benchmarking API */ if (load_bm_api( &bmb )!=0) { LM_ERR("can't load benchmark API\n"); goto error; } ... ... /* Start/log timers during a (usually user-exported) module function */ bmb.bm_register("test", 1, &id) bmb.bm_start(id); do_something(); bmb.bm_log(id); ``` -------------------------------- ### Get Trie Reload Status (opensips-cli MI) Source: https://github.com/vanminh2018/opensips-docs/blob/main/trie/README.txt Executes the 'dr_reload_status' Management Interface (MI) command via 'opensips-cli' to retrieve the timestamp of the last trie reload. This example shows usage when 'use_partitions' is 0. ```Shell $ opensips-cli -x mi dr_reload_status ``` -------------------------------- ### Setting default_str Parameter in OpenSIPS Script Source: https://github.com/vanminh2018/opensips-docs/blob/main/example/README.txt Configures the 'default_str' parameter for the 'example' module. This string value is used by the example_str() function when called without an argument. The default value is an empty string. ```OpenSIPS Script modparam("example", "default_str", "TEST") ``` -------------------------------- ### Blocking Media Stream with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Simple example showing the basic usage of the rtpengine_block_media function to block an RTP media stream. The direction to be blocked can be controlled by flags like 'from-tag'. ```OpenSIPS Script rtpengine_block_media(); ``` -------------------------------- ### Custom rtp_relay_copy_offer Route Example (OpenSIPS Script) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtp_relay/README.txt Provides an example of a custom `route_copy_offer` implementation. This route is intended to instruct a media engine (like RTPEngine) to fork the media stream. It returns a success code (1) and a handle (`$var(handle)`) which identifies the copy session and is stored by the `rtp_relay` module. ```OpenSIPS Script route[rtp_relay_copy_offer] { # instruct a media engine to fork media and assign an identifier # that shall be stored in the $var(handle) variable return (1, $var(handle)); } ``` -------------------------------- ### Blocking DTMF with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Simple example showing the basic usage of the rtpengine_block_dtmf function to block DTMF signals within an RTP stream. The direction to be blocked can be controlled by flags like 'from-tag'. ```OpenSIPS Script rtpengine_block_dtmf(); ``` -------------------------------- ### Configure OpenSIPS Node B for Clustering Source: https://github.com/vanminh2018/opensips-docs/blob/main/clusterer/README.txt Partial configuration snippet for OpenSIPS Node B, setting up its BIN listener and loading the proto_bin and clusterer modules as part of the cluster setup. ```opensips.cfg socket= bin:192.168.0.6:5566 # bin listener for Node B loadmodule "proto_bin.so" loadmodule "clusterer.so" ``` -------------------------------- ### Starting UA Client Session via MI OpenSIPS CLI Source: https://github.com/vanminh2018/opensips-docs/blob/main/b2b_entities/README.txt Demonstrates how to initiate a client-side UA session using the `ua_session_client_start` Management Interface (MI) command via `opensips-cli`. It specifies the RURI, To, From, and flags for the session. ```OpenSIPS CLI opensips-cli -x mi ua_session_client_start ruri=sip:bob@opensips.org \ to=sip:bob@opensips.org from=sip:alice@opensips.org flags=arhb ``` -------------------------------- ### Start Announcement Playback using OpenSIPS MI (Shell) Source: https://github.com/vanminh2018/opensips-docs/blob/main/media_exchange/README.txt This `opensips-cli` command uses the `media_exchange_from_call_to_uri` Management Interface (MI) function to start playing an announcement URI to the caller leg of a specific call ID. It demonstrates how to initiate a media session from a call to a specified URI. ```Shell opensips-cli -x mi media_exchange_from_call_to_uri \ callid=c6fdb0f9-47dc-495d-8d38-0f37e836a531 \ uri=sip:announcement@127.0.0.1:5080 \ leg=caller ``` -------------------------------- ### Compiling OpenSIPS Core and Modules Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Install-CompileAndInstall-3-6.txt This command compiles the OpenSIPS core along with all its configured modules. It should be executed from the root directory of the OpenSIPS source code. ```Shell make all ``` -------------------------------- ### Unblocking DTMF with RTPEngine (OpenSIPS) Source: https://github.com/vanminh2018/opensips-docs/blob/main/rtpengine/README.txt Simple example showing the basic usage of the rtpengine_unblock_dtmf function to resume previously blocked DTMF signals within an RTP stream. The direction can be controlled by flags like 'from-tag'. ```OpenSIPS Script rtpengine_unblock_dtmf(); ``` -------------------------------- ### Basic Preprocessing with `cat` in OpenSIPS Source: https://github.com/vanminh2018/opensips-docs/blob/main/0_docs/Templating-Config-Files-3-6.txt This command demonstrates the fundamental use of the OpenSIPS '-p' (preprocessor) option. It pipes the 'opensips.cfg' file through '/bin/cat', which simply echoes the input to standard output, serving as a basic example of how a preprocessor receives and returns configuration data. ```shell opensips -f opensips.cfg -p /bin/cat ``` -------------------------------- ### Install Compilation Dependencies for cachedb_mongodb (Debian/Ubuntu) Source: https://github.com/vanminh2018/opensips-docs/blob/main/cachedb_mongodb/README.txt This snippet provides the shell commands required to install the necessary development libraries (libjson-c-dev, libmongoc-dev, libbson-dev) for compiling the cachedb_mongodb module on Debian or Ubuntu systems using apt-get. ```Shell # Debian / Ubuntu sudo apt-get install libjson-c-dev libmongoc-dev libbson-dev ``` -------------------------------- ### Getting Perl Compilation Flags and Typemap Path Source: https://github.com/vanminh2018/opensips-docs/blob/main/perl/README.txt Provides shell commands to retrieve necessary compilation flags (ldopts, ccopts) and the path to the typemap file from the installed Perl environment. These values are required for cross-compiling the OpenSIPS Perl module. ```Shell PERLLDOPTS: perl -MExtUtils::Embed -e ldopts ``` ```Shell PERLCCOPTS: perl -MExtUtils::Embed -e ccopts ``` ```Shell TYPEMAP: echo "`perl -MConfig -e 'print $Config{installprivlib}'`/ExtUtils/typemap" ``` -------------------------------- ### Compiling and Installing MySQL Module - Shell Source: https://github.com/vanminh2018/opensips-docs/blob/main/db_mysql/README.txt Provides command-line instructions using make to compile and install OpenSIPS specifically including the db_mysql module. This is an alternative to modifying the Makefile directly when the module is not included by default. ```Shell 'make all include_modules="db_mysql"; make install include_modules="db_mysql"' ```