Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
Dial Plan Plugin Help
Author Message
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Tue Nov 01, 2016 4:18 pm    Post subject: Dial Plan Plugin Help Reply with quote

1. Brekeke Product Name and Version: Brekeke SIP Server 3.6.2.5

2. Java version:1.7

3. OS type and the version: 64-bit RHEL6.6

4. UA (phone), gateway or other hardware/software involved:

5. Your problem:Dial Plan Plugin Not Working


Here is what I did.

1. Created a CLASS_PATH environment variable with value
CLASS_PATH=/usr/local/apache-tomcat-7.0.72/webapps/sip/WEB-INF/lib/ondosip.jar

2. Created sni.java file with following content:
package plugin ;

import java.util.* ;

public class sni
{
static public String hello( String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr ) throws Exception
{
return ( "hello" ) ;
}

static public String get_sip_call_id( String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr ) throws Exception
{
String sipcallid = sippacket.getValue("Call-ID");
return ( sipcallid ) ;
}
}


3. Compiled it by "javac -g sni.java".
4. Created a jar file by "jar -tvf sni.jar sni.class"
5. copied the sni.jar file in /usr/local/apache-tomcat-7.0.72/webapps/sip/WEB-INF/lib
6. added the following line in a working DialPlan Matching Pattern
Matching Patterns
$sni.get_sip_call_id = (.+)

7. Added the following line in deploy pattern
$log = mydebug:%3

When the call comes in call it not matching on the dial plan. What am I doing wrong?
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 285
Location: Japan

PostPosted: Tue Nov 01, 2016 6:32 pm    Post subject: Reply with quote

For getting Call-ID, you just use "Call-ID = (.+)" in Matching Pattern.


> 7. Added the following line in deploy pattern
> $log = mydebug:%3

Why is it %3 not %1?

Try this.
Deploy Patterns
$log = mydebug:%{$sni.get_sip_call_id}

For debugging Dial Plan script, check "Dial Plan" in [Diagnostics]->[Debug Logs] page.
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed Nov 02, 2016 8:28 am    Post subject: Reply with quote

I appreciate your response. I know I can use Call-ID= (.+) in the matching pattern to get the value of call-id. But I was trying to write a simple pluging to see if it works or not.

Here is my complete matching and deploy patters

Matching Patterns
$addr = 10\.1\.1\.1
From = sip:(.+)@
$request = sip:123(.+)@
$getUri(Call-ID) = (.+)
$sni.get_sip_call_id = (.+)
Deploy Patterns
From = sip:%1@10.2.2.2
To = sip:%2@10.3.3.3
$b2bua = true
$rtp = false
$session = sdp
&sdp.audio.a.1 = ptime:20
&sdp.audio.a.2 = silenceSupp:off - - - -
Call-ID = B%3
$log = myDebug_BrekekeVar3:%3
$log = myDebug_myPluginVar4:%4

Eventually. my goal is to get the SIP CALL-ID from leg-A and prefix it with "B" and send it on leg-B.

Call is not matching on my dial plan because plugin may be returning null value.

Question1: I would appreciate if you can tell me what I am doing wrong in the plugin?
Question2: I went through the instructions mentioned on http://www.brekeke.com/doc/sip/sip_tutorial_dialplan_plugin.txt. Do I have to complete the step # 2 along with step # 1 under section 3. HOW TO INSTALL PLUGIN?
Question3: How Can I set the value of Call-ID in plugin, may be something like
sippacket.setValue( "header_name","header_value" )?
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 285
Location: Japan

PostPosted: Wed Nov 02, 2016 11:36 am    Post subject: Reply with quote

skb007...

Why are you adding "B" in Call-ID?
Using Call-ID like that is not good idea and will not work.
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Wed Nov 02, 2016 4:29 pm    Post subject: Reply with quote

Harold, There is a business logic behind this requirement which involves the CDR reconciliation. Please answer the three questions asked in the previous post.
Back to top
View user's profile
Harold
Brekeke Master Guru


Joined: 21 Sep 2008
Posts: 285
Location: Japan

PostPosted: Wed Nov 02, 2016 5:31 pm    Post subject: Reply with quote

Since this is User Discussion Forum, I recommend that you contact Brekeke's tech support if you want to develop own plugin.
http://www.brekeke.com/company/inquiry.php
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Fri Sep 29, 2017 2:48 pm    Post subject: Reply with quote

Harold, keeping business requirements aside, I would like to learn about the dial Plan plugins. I would appreciate if you can guide me for this simple plugin. I have modified the dial plan as per your suggestion.

Matching Patterns
$addr = 10\.1\.1\.1
From = sip:(.+)@
$request = sip:123(.+)@
Deploy Patterns
From = sip:%1@10.2.2.2
To = sip:%2@10.3.3.3
$b2bua = true
$rtp = false
$log = mydebug:%{$sni.get_sip_call_id}

I am getting the following error.

Code:
Rule: Error: class=com.brekeke.plugin.sni  method=get_sip_call_id  ex=java.lang.ClassNotFoundException: com.brekeke.plugin.sni

Rule: Error: class=com.brekeke.net.sip.sv.rule.matching.plugins.sni  method=get_sip_call_id  ex=java.lang.ClassNotFoundException: com.brekeke.net.sip.sv.rule.matching.plugins.sni

Rule: Error: class=com.brekeke.plugin.sni  method=doDispatch  ex=java.lang.ClassNotFoundException: com.brekeke.plugin.sni

Rule: Error: class=com.brekeke.net.sip.sv.rule.matching.plugins.sni  method=doDispatch  ex=java.lang.ClassNotFoundException: com.brekeke.net.sip.sv.rule.matching.plugins.sni
Back to top
View user's profile
Ericcc
Brekeke Member


Joined: 21 Apr 2014
Posts: 23
Location: NY, USA

PostPosted: Mon Oct 02, 2017 11:18 am    Post subject: Reply with quote

> method=get_sip_call_id ex=java.lang.ClassNotFoundException: com.brekeke.plugin.sni

The error message indicates that the plugin's class and/or method is not found.

What Java package path did you specify for the class sni?

Is it "package plugin"? If so, the package is "plugin".

Put the line below at [Configuration]->[Advanced] page, and restart the SIP Server,
-------------------------
dialplan.plugins.matching.pkg = plugin
-------------------------
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Mon Oct 02, 2017 12:44 pm    Post subject: Reply with quote

Ericcc, appreciate your response.

I have gone through the following steps:

Code:

1 ## Added the following.
  [Configuration]->[Advanced] --> dialplan.plugins.matching.pkg = plugin
2 ## Added classpath to environment
  CLASSPATH=/usr/local/apache-tomcat-7.0.72/webapps/sip/WEB-INF/lib/ondosip.jar

3 ##Created java code file.
  /home/skb007/java> vi sni.java

4 ##Complied the java file.
  /home/skb007/java> javac -g sni.java

5 ## Created the jar file.
  /home/skb007/java> jar -cvf sni.jar sni.class

6 ## check the contents of the jar file.
  /home/skb007/java> jar -tvf sni.jar
     0 Mon Oct 02 15:11:54 EDT 2017 META-INF/
    68 Mon Oct 02 15:11:54 EDT 2017 META-INF/MANIFEST.MF
   855 Mon Oct 02 15:09:38 EDT 2017 sni.class

7 ## copied the jar file to /usr/local/apache-tomcat-7.0.72/webapps/sip/WEB-INF/lib/
  /home/skb007/java> cp sni.jar /usr/local/apache-tomcat-7.0.72/webapps/sip/WEB-INF/lib/sni.jar

8 ## Restarted the Apache-Tomcat server
  /home/skb007/java> /usr/local/apache-tomcat-7.0.72/bin/shutdown.sh
  /home/skb007/java> /usr/local/apache-tomcat-7.0.72/bin/startup.sh


Following is the source code in the sni.java file

Code:

package  plugin ;

import java.util.* ;

public class sni
{
  static public String hello( String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr ) throws Exception
  {
    return ( "hello" ) ;
  }

  static public String get_sip_call_id( String[] arg, com.brekeke.net.sip.SIPpacket sippacket, Properties pr ) throws Exception
  {
    String sipcallid = sippacket.getValue("Call-ID");
    return ( sipcallid ) ;
  }
}



Following are Matching/Deploy pattern

Matching Patterns
$addr = 10\.1\.1\.1
From = sip:(.+)@
$request = sip:123(.+)@
Deploy Patterns
From = sip:%1@10.2.2.2
To = sip:%2@10.3.3.3
$b2bua = true
$rtp = false
$log = mydebug:%{$sni.get_sip_call_id}

I am still getting the following errors:


Code:

Rule: Error: class=plugin.sni  method=get_sip_call_id  ex=java.lang.ClassNotFoundException: plugin.sni

Rule: Error: class=com.brekeke.net.sip.sv.rule.matching.plugins.sni  method=get_sip_call_id  ex=java.lang.ClassNotFoundException: com.brekeke.net.sip.sv.rule.matching.plugins.sni

Rule: Error: class=plugin.sni  method=doDispatch  ex=java.lang.ClassNotFoundException: plugin.sni

Rule: Error: class=com.brekeke.net.sip.sv.rule.matching.plugins.sni  method=doDispatch  ex=java.lang.ClassNotFoundException: com.brekeke.net.sip.sv.rule.matching.plugins.sni

Back to top
View user's profile
Ericcc
Brekeke Member


Joined: 21 Apr 2014
Posts: 23
Location: NY, USA

PostPosted: Mon Oct 02, 2017 4:34 pm    Post subject: Reply with quote

> 5 ## Created the jar file.
> /home/skb007/java> jar -cvf sni.jar sni.class

Since the package is "plugin", you need a folder named "plugin".

1) mkdir plugin

2) mv sni.* plugin

3) javac plugin/sni.java

4) jar -cvf sni.jar plugin/sni.class
Back to top
View user's profile
skb007
Brekeke Guru


Joined: 05 Oct 2015
Posts: 152
Location: USA

PostPosted: Tue Oct 03, 2017 3:46 pm    Post subject: Reply with quote

Ericcc,

Yayyyyy...my plugin is working now. I appreciate your help.
I went through the developer guide documentation and I did not find any sample how to manipulate the SDP. Will you be able to provide me some more samples for the plugins with access to SDP.
Back to top
View user's profile
Ericcc
Brekeke Member


Joined: 21 Apr 2014
Posts: 23
Location: NY, USA

PostPosted: Tue Oct 03, 2017 4:26 pm    Post subject: Reply with quote

Is it the purpose of DialPlan plugin?

Note that DialPlan plugin is executed with each initial INVITE only.
It means you can manipulate first SDP attached in an initial INVITE.

If you want to manipulate all SDP including 200 OK's and re-INVITE's, you need to use Session Plugin instead of DialPlan plugin.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1