Re: [OpenSIPS-Devel] [opensips] date format convert method that use in opensips.cfg (#378)

2014-10-29 Thread Di-Shi Sun
It is possible to use get_timestamp to generate date/time string in GMT. :)

It should be easier and enough to add a pvar for time in GMT if you only want 
to generate SIP Date header.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/378#issuecomment-60883185___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 @@ -332,6 +332,76 @@ exec_getenv(HOSTNAME, $avp(localhost));
   /example
   /section
  
 + section
 + title
 + function moreinfo=noneexec(command, [output], [input], 
 [error],[envavp])/function

Could you change that to [input], [output], [error] ? That makes sense for 
everyone familiar with standard unix convention (0=stdin, 1=stdout, 2=stderr). 
It's not too late to fix now.

And add a space before `[envavp]`.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19524707___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + paraemphasiserror/emphasis - pseudovariable where 
 to store the error from
 + the standard error of the process.
 + /para
 + /listitem
 + listitem
 + paraemphasisenvavp/emphasis - Avp where to store 
 the values for the
 + environment variables to be passed for the command. The 
 names of the environment
 + variables will be OSIPS_EXEC_# where # will start 
 from 0. For example if you
 + store 2 values into an avp (a and b) OSIPS_EXEC_0 
 will contain the first value
 + and OSIPS_EXEC_1 the second value.
 + /para
 + /listitem
 + /itemizedlist
 + para
 + WARNING: any OpenSIPS pseudo-vars which may contain special bash
 + characters should be placed inside quotes, e.g. 
 exec(update-stats.sh '$ct');

This does not help. You need to quote the contents of $ct too, or else I could 
do this:

Contact: sip:'; rm -rf /; echo '@whatever.com

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19524753___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + para
 + WARNING: input/output/error parameters are not designed 
 for a large amount of
 + data so one should be careful when using them because server 
 could considerably be
 + slowed down.
 + /para
 + para
 + This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
 + LOCAL_ROUTE, STARTUP_ROUTE, TIMER_ROUTE, EVENT_ROUTE, 
 ONREPLY_ROUTE.
 + /para
 + example
 + titlefunction moreinfo=noneexec/function usage/title
 + programlisting format=linespecific
 +...
 +$avp(env) = a;
 +$avp(env) = b;
 +exec(ls -l, $var(out),, $avp(env));

This example does not take stderr into account.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19524764___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + /para
 + para
 + This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
 + LOCAL_ROUTE, STARTUP_ROUTE, TIMER_ROUTE, EVENT_ROUTE, 
 ONREPLY_ROUTE.
 + /para
 + example
 + titlefunction moreinfo=noneexec/function usage/title
 + programlisting format=linespecific
 +...
 +$avp(env) = a;
 +$avp(env) = b;
 +exec(ls -l, $var(out),, $avp(env));
 +xlog(The output is $var(out)\n);
 +...
 +$var(input) = input;
 +exec(/home/../myscript.sh,, this is my $var(input) for exec\n, 
 $avp(env));

Nor does this.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19524771___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 @@ -51,6 +51,7 @@ int schedule_to_kill( int pid );
   * @stream: stream to be returned to the caller
   */
  pid_t __popen(const char *cmd, const char *type, FILE **stream);
 +pid_t ___popen(const char *cmd, FILE **, FILE**, FILE**);

That's not very inventively named, is it? :-D

Python popen2 lib called it popen3:

popen2.popen3(cmd[, bufsize[, mode]])

Perhaps `__popen3` is a better name.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19525000___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + if ((buflen + tmplen) = MAX_BUF_SIZE) {
 + LM_WARN(no more space in output buffer\n);
 + break;
 + }
 + memcpy(buf+buflen, tmpbuf, tmplen);
 + buflen += tmplen;
 +
 + outval.flags = PV_VAL_STR;
 + outval.rs.s = buf;
 + outval.rs.len = buflen;
 +
 + if (buflen 
 + pv_set_value(msg, outvar-v.pve-spec, 0, outval)  
 0) {
 + LM_ERR(cannot set output pv value\n);
 + return -1;
 + }

Seems redundant to re-set outval.flags and rs.s every iteration (and rs.len for 
that matter).

Shouldn't you move everything from outval.flags to the end of this block to 
outside the `while{}`?

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19525189___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] date format convert method that use in opensips.cfg (#378)

2014-10-29 Thread xiaoqiang.zhou
I think the function get_timestamp return current system time. but current 
system timezone not GMT. 
so get_timestamp return value is not GMT.
may be have something that I miss it , please tell me.





zhouxiaoqiang.mst...@gmail.com
 
From: Di-Shi Sun
Date: 2014-10-29 15:24
To: OpenSIPS/opensips
CC: xiaoqiang.zhou
Subject: Re: [opensips] date format convert method that use in opensips.cfg 
(#378)
It is possible to use get_timestamp to generate date/time string in GMT. :)
It should be easier and enough to add a pvar for time in GMT if you only want 
to generate SIP Date header.
—
Reply to this email directly or view it on GitHub.


---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/378#issuecomment-60890517___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + goto error;
 + }
 +
 + if (ferror(pin)) {
 + ser_error=E_EXEC;
 + goto error;
 + }
 + pclose(pin);
 + }
 +
 + schedule_to_kill(pid);
 + wait(exit_status);
 +
 + if (outvar) {
 + if (read_and_write2var(msg, pout, outvar)  0) {
 + LM_ERR(failed reading from pipe\n);

+ stdout

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19525389___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + return -1;
 + }
 + }
 +
 + if (errvar) {
 + if (read_and_write2var(msg, perr, errvar)  0) {
 + LM_ERR(failed reading stderr from pipe\n);
 + return -1;
 + }
 + }
 +
 + ret=1;
 +
 +error:
 + if (outvar  ferror(pout)) {
 + LM_ERR(reading pipe: %s\n, strerror(errno));

`+ stdout`

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19525424___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
 + }
 + return 0;
 +}
 +
 +static inline int setenvvar(struct hf_wrapper** hf, int_str* value, int idx)
 +{
 + #define OSIPS_EXEC OSIPS_EXEC_
 +
 +
 + int len=0;
 + str sidx;
 +
 + sidx.s = int2str((unsigned long)idx, sidx.len);
 +
 + (*hf)-envvar=pkg_malloc(strlen(OSIPS_EXEC) + sidx.len + 1/*=*/
 + + (*value).s.len + 1/*\0*/);

`(*value).s` == `value-s`, the latter is more common.

Applies to this entire function.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375/files#r19525529___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] added exec(cmd, output, input, error, avpenv) function for exec (#375)

2014-10-29 Thread Walter Doekes
Thanks for fixing the other issues :)

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/pull/375#issuecomment-60891337___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] date format convert method that use in opensips.cfg (#378)

2014-10-29 Thread Di-Shi Sun
First, I was joking. It is definitely not a good idea to use get_timestamp (or 
other pvars such as $Ts) to generate GMT time string. But it is possible. If 
you read the code of OpenSIPS, you can see it uses C gettimeofday and time 
functions to get the number of seconds and microseconds since the Epoch. They 
are not timezone depending. As long as you set the correct timezone, you can 
get correct time in seconds from the Epoch. And then, you can generate correct 
time string in GMT.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/378#issuecomment-60893522___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] [opensips] date format convert method that use in opensips.cfg (#378)

2014-10-29 Thread xiaoqiang.zhou
Hi:
I do it.  if set GMT timezone for system, it will work fine.



zhouxiaoqiang.mst...@gmail.com
 
From: Di-Shi Sun
Date: 2014-10-29 17:21
To: OpenSIPS/opensips
CC: xiaoqiang.zhou
Subject: Re: [opensips] date format convert method that use in opensips.cfg 
(#378)
First, I was joking. It is definitely not a good idea to use get_timestamp (or 
other pvars such as $Ts) to generate GMT time string. But it is possible. If 
you read the code of OpenSIPS, you can see it uses C gettimeofday and time 
functions to get the number of seconds and microseconds since the Epoch. They 
are not timezone depending. As long as you set the correct timezone, you can 
get correct time in seconds from the Epoch. And then, you can generate correct 
time string in GMT.
—
Reply to this email directly or view it on GitHub.


---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/378#issuecomment-60903825___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel


Re: [OpenSIPS-Devel] OpenSIPS Public Meeting - WebRTC

2014-10-29 Thread Răzvan Crainea

Hi, all!

Don't forget about the WebRTC meeting that's going to happen in about 
one hour!


Best regards,

Răzvan Crainea
OpenSIPS Solutions
www.opensips-solutions.com

On 10/23/2014 09:48 PM, Bogdan-Andrei Iancu wrote:

As a starting point for the discussion, please take a look at:
http://www.opensips.org/Documentation/Tutorials-WebSocket

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 23.10.2014 20:53, Răzvan Crainea wrote:

Hello, all!

The next public meeting will take place on IRC Wednesday, 29th of 
October 2014, at 17:00 EET[1]. The topic of the meeting is to discuss 
whether we should integrate WebRTC in OpenSIPS or not.

Make sure you don't miss it, your opinion is important to us!

[1] 
http://www.timeanddate.com/worldclock/fixedtime.html?msg=OpenSIPS+Public+Meeting+-+WebRTCiso=20141029T17p1=49ah=1

[2] http://www.opensips.org/Community/IRCmeeting20141029

Best regards,



___
Users mailing list
us...@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



___
Devel mailing list
Devel@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel