THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Juha Heinanen (jh)
Attached to Project - sip-router
Summary - tls module 'config' param can point to directory
Task Type - Improvement
Category - tls
Status - Assigned
Assigned To - Andrei Pelinescu-Onciul
Operating System - All
Severity - Medium
Priority - Normal
Reported Version - Development
Due in Version - Undecided
Due Date - Undecided
Details - i modified tls/tls_config.c tls_load_config() function so that it checks if file pointed to by 'config' module param is a directory. if it is, tls_load_config() copies all regular files of that directory to a tmp file and then passes that tmp file to cfg_parser. that way config parser can stay as is.
reason for this improvement is that it is easier from management point of view to add/remove files when peers come and go rather than edit a monolithic single config file. modified tls_load_config() is below. feel free to implement same functionality in some other way. i don't care how it is done as long as the feature is available. if adopted, i'll update README accordingly.
-- juha
------------------------------------------------------------------------------------------------------------------
/*
* Create configuration structures from configuration file
*/
tls_domains_cfg_t* tls_load_config(str* filename)
{
cfg_parser_t* parser;
str empty;
struct stat file_status;
char tmp_name[13] = "configXXXXXX";
str filename_str;
DIR *dir;
struct dirent *ent;
int out_fd, in_fd, filename_is_directory;
char *file_path, ch;
parser = NULL;
memset(&file_status, 0, sizeof(struct stat));
dir = (DIR *)NULL;
in_fd = out_fd = filename_is_directory = 0;
file_path = (char *)0;
if ((cfg = tls_new_cfg()) == NULL) goto error;
if (stat(filename->s, &file_status) != 0) {
LOG(L_ERR, "cannot stat config file %s\n", filename->s);
goto error;
}
if (S_ISDIR(file_status.st_mode)) {
filename_is_directory = 1;
dir = opendir(filename->s);
if (dir == NULL) {
LOG(L_ERR, "cannot open directory file %s\n", filename->s);
goto error;
}
out_fd = mkstemp(&(tmp_name[0]));
if (out_fd == -1) {
LOG(L_ERR, "cannot make tmp file %s\n", &(tmp_name[0]));
goto error;
}
while ((ent = readdir(dir)) != NULL) {
file_path = pkg_malloc(filename->len + 1 + 256);
memcpy(file_path, filename->s, filename->len);
file_path[filename->len] = '/';
strcpy(file_path + filename->len + 1, ent->d_name);
if (stat(file_path, &file_status) != 0) {
LOG(L_ERR, "cannot get status of config file %s\n",
file_path);
goto error;
}
if (S_ISREG(file_status.st_mode)) {
in_fd = open(file_path, O_RDONLY);
if (in_fd == -1) {
LOG(L_ERR, "cannot open config file %s\n",
file_path);
goto error;
}
pkg_free(file_path);
while (read(in_fd, &ch, 1)) {
write(out_fd, &ch, 1);
}
close(in_fd);
in_fd = 0;
ch = '\n';
write(out_fd, &ch, 1);
}
}
closedir(dir);
close(out_fd);
dir = (DIR *)NULL;
out_fd = 0;
}
empty.s = 0;
empty.len = 0;
if (filename_is_directory) {
filename_str.s = &(tmp_name[0]);
filename_str.len = strlen(&(tmp_name[0]));
if ((parser = cfg_parser_init(&empty, &filename_str)) == NULL) {
ERR("tls: Error while initializing configuration file parser.\n");
unlink(&(tmp_name[0]));
goto error;
}
unlink(&(tmp_name[0]));
} else {
if ((parser = cfg_parser_init(&empty, filename)) == NULL) {
ERR("tls: Error while initializing configuration file parser.\n");
goto error;
}
}
cfg_section_parser(parser, parse_domain, NULL);
if (sr_cfg_parse(parser)) goto error;
cfg_parser_close(parser);
return cfg;
error:
if (dir) closedir(dir);
if (out_fd > 0) {
close(out_fd);
unlink(&(tmp_name[0]));
}
if (file_path) pkg_free(file_path);
if (parser) cfg_parser_close(parser);
if (cfg) tls_free_cfg(cfg);
return 0;
}
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=89
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A user has added themself to the list of users assigned to this task.
FS#89 - tls module 'config' param can point to directory
User who did this - Juha Heinanen (jh)
http://sip-router.org/tracker/index.php?do=details&task_id=89
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
Hi, from an external library function I get a pointer to a \0
terminated string, and I want to get such string as PV value. In the
module code I do:
------------------------------
static str *external_lib_reply;
[...]
static int child_init(int rank)
{
external_lib_reply = pkg_malloc(sizeof(str*));
}
[...]
static int pv_get_external_lib_reply(struct sip_msg *msg, pv_param_t
*param, pv_value_t *res)
{
if (! *external_lib_reply->s) {
LM_ERR("pv 'external_lib_reply' doesn't have value\n");
return pv_get_null(msg, param, res);
}
else {
return pv_get_strval(msg, param, res, external_lib_reply);
}
}
[...]
// Exported module function:
static int w_external_lib_do_request(struct sip_msg* _msg, char* _s1,
char* _s2) {
// Here I get a \0 terminated pointer to char:
char *replied_string;
[...]
replied_string = [...];
// Then I want to assign its value to the PV:
// line 209:
*external_lib_reply->s = replied_string;
// line 210:
*external_lib_reply->len = strlen(replied_string);
[...]
}
-----------------------------
I get compilation error in this last part:
209: warning: assignment makes integer from pointer without a cast
210: error: invalid type argument of ‘unary *’ (have ‘int’)
I don't understand the reason of the warning neither the reason of the
error. Any help please?
Thanks a lot.
--
Iñaki Baz Castillo
<ibc(a)aliax.net>
when permissions module is initialized and permissions.allow does not
exist, i get these warnings:
Oct 2 12:08:40 sip /usr/sbin/sip-proxy[10430]: WARNING: permissions [parse_config.c:251]: parse_config_file(): file not found: /etc/sip-proxy/permissions.allow
Oct 2 12:08:40 sip /usr/sbin/sip-proxy[10430]: WARNING: permissions [permissions.c:606]: mod_init(): default allow file (/etc/sip-proxy/permissions.allow) not found => empty rule set
in my opinion WARNING level to too high, because it is perfectly normal
that this file does not exist.
is it ok if i lower these WARNINGs to INFOs?
-- juha
Hi, I'm coding a new module but I'm getting lost when trying to
compile the whole sources. Basically I've created my own local branch
(starting from master branch):
~# git clone --depth 1 git://git.sip-router.org/sip-router sip-router
~# cd sip-router
~# git checkout -b ibc
Then I write my new module under modules/ directory (or perhaps should
I do it under modules_k/ ?). I'd prefer to do it under modules/ as the
module has no MI feature, neither other specific flavour dependencies.
And then I just want to compile the sources using kamailio flavour (as
I'm not used to 'ser'), so I want to get 'kamailio' binary and
/etc/kamailio/ directory.
How to do this? Which is the preferred way to create a new module?
should I do just "make & make install"? I remember some threads about
it in this maillist without an easy conclusion so I ask you for help.
Thanks a lot.
PS: Please, merge :)
--
Iñaki Baz Castillo
<ibc(a)aliax.net>
Module: sip-router
Branch: master
Commit: 94c8e2f47db786e3ed3fccbf103562ec76233a7d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=94c8e2f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Sep 24 11:53:38 2010 +0200
rtpproxy: return -2 for force_rtp_proxy if rtpproxy was already used
- patch by Alex Hermann, closed SF#3035804
---
modules_k/rtpproxy/README | 103 ++++++++++++++++++++++++-----
modules_k/rtpproxy/doc/rtpproxy_admin.xml | 5 ++
modules_k/rtpproxy/rtpproxy.c | 2 +-
3 files changed, 91 insertions(+), 19 deletions(-)
diff --git a/modules_k/rtpproxy/README b/modules_k/rtpproxy/README
index 94c2ec0..df60fb7 100644
--- a/modules_k/rtpproxy/README
+++ b/modules_k/rtpproxy/README
@@ -54,6 +54,8 @@ Sas Ovidiu
4.4. rtpproxy_retr (integer)
4.5. force_socket (string)
4.6. nortpproxy_str (string)
+ 4.7. timeout_socket (string)
+ 4.8. timeout_socket_type (int)
5. Exported Functions
@@ -69,6 +71,9 @@ Sas Ovidiu
5.8. start_recording()
6. Exported Pseudo Variables
+
+ 6.1. $rtpstart
+
7. MI Commands
7.1. nh_enable_rtpp
@@ -84,15 +89,18 @@ Sas Ovidiu
1.4. Set rtpproxy_retr parameter
1.5. Set force_socket parameter
1.6. Set nortpproxy_str parameter
- 1.7. fix_nated_contact usage
- 1.8. force_rtp_proxy usage
- 1.9. rtpproxy_offer usage
- 1.10.
- 1.11. unforce_rtp_proxy usage
- 1.12. rtpproxy_stream2xxx usage
- 1.13. start_recording usage
- 1.14. nh_enable_rtpp usage
- 1.15. nh_show_rtpp usage
+ 1.7. Set timeout_socket parameter
+ 1.8. Set timeout_socket_type parameter
+ 1.9. fix_nated_contact usage
+ 1.10. force_rtp_proxy usage
+ 1.11. rtpproxy_offer usage
+ 1.12.
+ 1.13. unforce_rtp_proxy usage
+ 1.14. rtpproxy_stream2xxx usage
+ 1.15. start_recording usage
+ 1.16. $rtpstat-Usage
+ 1.17. nh_enable_rtpp usage
+ 1.18. nh_show_rtpp usage
Chapter 1. Admin Guide
@@ -113,6 +121,8 @@ Chapter 1. Admin Guide
4.4. rtpproxy_retr (integer)
4.5. force_socket (string)
4.6. nortpproxy_str (string)
+ 4.7. timeout_socket (string)
+ 4.8. timeout_socket_type (int)
5. Exported Functions
@@ -128,6 +138,9 @@ Chapter 1. Admin Guide
5.8. start_recording()
6. Exported Pseudo Variables
+
+ 6.1. $rtpstart
+
7. MI Commands
7.1. nh_enable_rtpp
@@ -193,6 +206,8 @@ Chapter 1. Admin Guide
4.4. rtpproxy_retr (integer)
4.5. force_socket (string)
4.6. nortpproxy_str (string)
+ 4.7. timeout_socket (string)
+ 4.8. timeout_socket_type (int)
4.1. rtpproxy_sock (string)
@@ -281,6 +296,40 @@ Note
modparam("rtpproxy", "nortpproxy_str", "a=sdpmangled:yes\r\n")
...
+4.7. timeout_socket (string)
+
+ The parameter sets timeout socket, which is transmitted to the
+ RTP-Proxy.
+
+ If it is an empty string, no timeout socket will be transmitted to the
+ RTP-Proxy.
+
+ Default value is “”.
+
+ Example 1.7. Set timeout_socket parameter
+...
+modparam("nathelper", "timeout_socket", "http://127.0.0.1:8000/RPC2")
+...
+
+4.8. timeout_socket_type (int)
+
+ The parameter sets type of the timeout socket, which is transmitted to
+ the RTP-Proxy.
+
+ If it is not set, type 1 (Kamailio XML-RPC-Socket) is transmitted to
+ the RTP-Proxy.
+
+ Default value is “1”.
+
+ Example 1.8. Set timeout_socket_type parameter
+...
+modparam("nathelper", "timeout_socket_type", 42)
+...
+
+ The only supported Type on the RTP-Proxy is currently “1” or “0” which
+ is the default socket-type of the RTP-Proxy which is not compatible to
+ Kamailio.
+
5. Exported Functions
5.1. set_rtp_proxy_set()
@@ -302,7 +351,7 @@ modparam("rtpproxy", "nortpproxy_str", "a=sdpmangled:yes\r\n")
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
BRANCH_ROUTE.
- Example 1.7. fix_nated_contact usage
+ Example 1.9. fix_nated_contact usage
...
set_rtp_proxy_set("2");
force_rtp_proxy();
@@ -384,10 +433,14 @@ force_rtp_proxy();
100ms saves two thirds of the network bandwith.
* ip_address - new SDP IP address.
+ It returns value -2 when a rtp proxy has already mangled the packet,
+ making possible to determine in the script if an rtpproxy is in the
+ audio path.
+
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
- Example 1.8. force_rtp_proxy usage
+ Example 1.10. force_rtp_proxy usage
...
if (search("User-Agent: Cisco ATA.*") {force_rtp_proxy();};
if (src_ip=1.2.3.4) {force_rtp_proxy("i");};
@@ -407,7 +460,7 @@ if (search("User-Agent: Cisco ATA.*") {force_rtp_proxy("","1.2.3.4");};
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
- Example 1.9. rtpproxy_offer usage
+ Example 1.11. rtpproxy_offer usage
route {
...
if (is_method("INVITE")) {
@@ -452,7 +505,7 @@ onreply_route[2]
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
- Example 1.10.
+ Example 1.12.
See rtpproxy_offer() function example above for example.
@@ -463,7 +516,7 @@ onreply_route[2]
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
- Example 1.11. unforce_rtp_proxy usage
+ Example 1.13. unforce_rtp_proxy usage
...
unforce_rtp_proxy();
...
@@ -500,7 +553,7 @@ rtpproxy_stream2uas(prompt_name, count)
-1 means that it will be streaming in loop indefinitely, until
appropriate rtpproxy_stop_stream2xxx is issued.
- Example 1.12. rtpproxy_stream2xxx usage
+ Example 1.14. rtpproxy_stream2xxx usage
...
if (is_method("INVITE")) {
rtpproxy_offer();
@@ -528,13 +581,27 @@ rtpproxy_stream2uas(prompt_name, count)
This function can be used from REQUEST_ROUTE and ONREPLY_ROUTE.
- Example 1.13. start_recording usage
+ Example 1.15. start_recording usage
...
start_recording();
...
6. Exported Pseudo Variables
+ 6.1. $rtpstart
+
+6.1. $rtpstart
+
+ Returns the RTP-Statistics from the RTP-Proxy. The RTP-Statistics from
+ the RTP-Proxy are provided as a string and it does contain several
+ packet-counters. The statistics must be retrieved before the session is
+ deleted (before unforce_rtpproxy).
+
+ Example 1.16. $rtpstat-Usage
+...
+ append_hf("X-RTP-Statistics: $rtpstat\r\n");
+...
+
7. MI Commands
7.1. nh_enable_rtpp
@@ -553,7 +620,7 @@ start_recording();
NOTE: if a rtpproxy is defined multiple times (in the same or diferente
sete), all its instances will be enables/disabled.
- Example 1.14. nh_enable_rtpp usage
+ Example 1.17. nh_enable_rtpp usage
...
$ kamctl fifo nh_enable_rtpp udp:192.168.2.133:8081 0
...
@@ -565,7 +632,7 @@ $ kamctl fifo nh_enable_rtpp udp:192.168.2.133:8081 0
No parameter.
- Example 1.15. nh_show_rtpp usage
+ Example 1.18. nh_show_rtpp usage
...
$ kamctl fifo nh_show_rtpp
...
diff --git a/modules_k/rtpproxy/doc/rtpproxy_admin.xml b/modules_k/rtpproxy/doc/rtpproxy_admin.xml
index 0074b6d..2bf5cac 100644
--- a/modules_k/rtpproxy/doc/rtpproxy_admin.xml
+++ b/modules_k/rtpproxy/doc/rtpproxy_admin.xml
@@ -419,6 +419,11 @@ force_rtp_proxy();
</para></listitem>
</itemizedlist>
<para>
+ It returns value -2 when a rtp proxy has already mangled the
+ packet, making possible to determine in the script if an
+ rtpproxy is in the audio path.
+ </para>
+ <para>
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
FAILURE_ROUTE, BRANCH_ROUTE.
</para>
diff --git a/modules_k/rtpproxy/rtpproxy.c b/modules_k/rtpproxy/rtpproxy.c
index 3680099..494cda0 100644
--- a/modules_k/rtpproxy/rtpproxy.c
+++ b/modules_k/rtpproxy/rtpproxy.c
@@ -2005,7 +2005,7 @@ force_rtp_proxy(struct sip_msg* msg, char* str1, char* str2, int offer)
}
}
if (proxied != 0 && force == 0) {
- FORCE_RTP_PROXY_RET (-1);
+ FORCE_RTP_PROXY_RET (-2);
}
/*
* Parsing of SDP body.
Hello,
some of us will be next Wednesday in Vienna, Austria and planned to have
a dinner - among the things to celebrate is the 3.1 release.
If you are around and want to join us, drop me an email. So far, from
registered developers, there will be myself, Klaus Darilion, Andreas
Graning and maybe Jon Bonilla. Time should be 19:00, place not decided
yet - it will be provided by email.
It is the usual social-networking-like event we had in the past,
everyone paying for himself/herself. Anyone is welcome to join!
Cheers,
Daniel
--
Daniel-Constantin Mierla
http://www.asipto.com