Revision: f2f79821c8f7
Author:   dmisol <[email protected]>
Date:     Mon Jul 29 10:24:14 2013
Log:      up to processing CRCX Resp

http://code.google.com/p/isup2sip/source/detail?r=f2f79821c8f7

Added:
/core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/CauseCodeMapping.java
 /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/CodingShemes.java
Modified:
 /core/bootstrap/pom.xml
 /core/bootstrap/src/main/assembly/descriptor.xml
 /core/bootstrap/src/main/config/META-INF/jboss-beans.xml
 /core/domain/src/main/java/org/mobicents/isup2sip/management/Channel.java
/core/domain/src/main/java/org/mobicents/isup2sip/management/CicManagement.java /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipManagement.java /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipPropertiesManagement.java
 /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/Isup2SipSbb.java
 /core/slee/sbbs/src/main/resources/META-INF/sbb-jar.xml

=======================================
--- /dev/null
+++ /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/CauseCodeMapping.java Mon Jul 29 10:24:14 2013
@@ -0,0 +1,46 @@
+package org.mobicents.isup2sip.sbb;
+
+public class CauseCodeMapping {
+               public static int statusToCause(int status){
+                       switch(status){
+ case 400: return 41;//Bad Request 41 Temporary Failure + case 401: return 21;//Unauthorized 21 Call rejected (*) + case 402: return 21 ;//Payment required 21 Call rejected
+                       case 403: return 21;//Forbidden                         
21 Call rejected
+ case 404: return 1;//Not found 1 Unallocated number + case 405: return 63;//Method not allowed 63 Service or option unavailable + case 406: return 79;//Not acceptable 79 Service/option not implemented (+) + case 407: return 21;//Proxy authentication required 21 Call rejected (*) + case 408: return 102;//Request timeout 102 Recovery on timer expiry + case 410: return 22;//Gone 22 Number changed (w/o diagnostic) + case 413: return 127;//Request Entity too long 127 Interworking (+) + case 414: return 127;//Request-URI too long 127 Interworking (+) + case 415: return 79;//Unsupported media type 79 Service/option not implemented (+) + case 416: return 127;//Unsupported URI Scheme 127 Interworking (+) + case 420: return 127;//Bad extension 127 Interworking (+) + case 421: return 127;//Extension Required 127 Interworking (+) + case 423: return 127;//Interval Too Brief 127 Interworking (+) + case 480: return 18;//Temporarily unavailable 18 No user responding + case 481: return 41;//Call/Transaction Does not Exist 41 Temporary Failure + case 482: return 25;//Loop Detected 25 Exchange - routing error + case 483: return 25;//Too many hops 25 Exchange - routing error + case 484: return 28;//Address incomplete 28 Invalid Number Format (+) + case 485: return 1;//Ambiguous 1 Unallocated number
+                       case 486: return 17;//Busy here                         
17 User busy
+//                     case 487: return ;//Request Terminated               
--- (no mapping)
+// case 488: return ;//Not Acceptable here --- by Warning header + case 500: return 41;//Server internal error 41 Temporary failure + case 501: return 79;//Not implemented 79 Not implemented, unspecified + case 502: return 38;//Bad gateway 38 Network out of order + case 503: return 41;//Service unavailable 41 Temporary failure +// case 504: return 102;//Server time-out 102 Recovery on timer expiry + case 504: return 127;//Version Not Supported 127 Interworking (+) + case 513: return 127;//Message Too Large 127 Interworking (+)
+                       case 600: return 17;//Busy everywhere                   
17 User busy
+                       case 603: return 21;//Decline                           
21 Call rejected
+ case 604: return 1;//Does not exist anywhere 1 Unallocated number +// case 606: return ;//Not acceptable --- by Warning header
+                       }
+                       return 16;              //"Normal clearing"
+               }
+}
=======================================
--- /dev/null
+++ /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/CodingShemes.java Mon Jul 29 10:24:14 2013
@@ -0,0 +1,10 @@
+package org.mobicents.isup2sip.sbb;
+
+public class CodingShemes {
+       public static String numberFromURI(String uri){
+               if(uri.toLowerCase().startsWith("sip:")){
+                       return uri.substring(uri.indexOf(':') + 1, 
uri.indexOf('@'));
+               }
+               return uri.substring(0, uri.indexOf('@'));
+       }
+}
=======================================
--- /core/bootstrap/pom.xml     Mon Jul 29 06:28:57 2013
+++ /core/bootstrap/pom.xml     Mon Jul 29 10:24:14 2013
@@ -109,13 +109,6 @@
                        <version>${jss7.mobicents.version}</version>
                </dependency>

-               <!-- Hardware Dialogic Java -->
-               <dependency>
-                       <artifactId>mobicents-dialogic</artifactId>
-                       <groupId>org.mobicents.protocols.ss7.hardware</groupId>
-                       <version>${jss7.mobicents.version}</version>
-               </dependency>
-
                <!-- MTP -->
                <dependency>
                        <artifactId>mtp</artifactId>
=======================================
--- /core/bootstrap/src/main/assembly/descriptor.xml Mon Jul 29 06:28:57 2013 +++ /core/bootstrap/src/main/assembly/descriptor.xml Mon Jul 29 10:24:14 2013
@@ -11,7 +11,6 @@
                        <unpack>false</unpack>
                        <scope>runtime</scope>
                        <includes>
-                               <!-- CAMEL libraries -->
                                
<include>org.mobicents.isup2sip:bootstrap</include>

                                <!-- rules and domain library -->
@@ -48,8 +47,6 @@
<include>org.mobicents.protocols.ss7.management:shell-server-api</include> <include>org.mobicents.protocols.ss7.management:shell-server-impl</include>
                                
<include>org.mobicents.protocols.ss7.hardware:linkset</include>
- <!-- <include>org.mobicents.protocols.ss7.hardware:mobicents-dahdi</include> --> - <include>org.mobicents.protocols.ss7.hardware:mobicents-dialogic</include>
                                
<include>org.mobicents.protocols.ss7.congestion:congestion</include>
                                
<include>org.mobicents.protocols.ss7:mobicents-ss7</include>
                        </includes>
=======================================
--- /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Mon Jul 29 06:28:57 2013 +++ /core/bootstrap/src/main/config/META-INF/jboss-beans.xml Mon Jul 29 10:24:14 2013
@@ -55,13 +55,6 @@
                </property>
        </bean>

- <!-- ==================================================================== -->
-       <!-- Dialogic Mtp3UserPart -->
- <!-- ==================================================================== --> - <!-- <bean name="Mtp3UserPart" class="org.mobicents.ss7.hardware.dialogic.DialogicMtp3UserPart"> - <property name="sourceModuleId">61</property> <property name="destinationModuleId">34</property>
-               </bean> -->
-
<!-- ==================================================================== -->
        <!-- ISUP Service -->
<!-- ==================================================================== -->
@@ -74,7 +67,7 @@
                        <parameter>
                                <inject bean="SS7Scheduler" />
                        </parameter>
-                       <parameter>22234</parameter>
+                       <parameter>111</parameter>
                        <parameter>2</parameter>
                </constructor>
                <property name="mtp3UserPart">
@@ -128,5 +121,9 @@
                        <parameter>Isup2SipManagement</parameter>
                </constructor>
                <property name="persistDir">${jboss.server.data.dir}</property>
+               <property name="gateway">192.168.1.13:2427</property>
+               <property name="remoteSPC">222</property>
+               <property name="persistDir">${jboss.server.data.dir}</property>
+
        </bean>
 </deployment>
=======================================
--- /core/domain/src/main/java/org/mobicents/isup2sip/management/Channel.java Mon Jul 29 06:28:57 2013 +++ /core/domain/src/main/java/org/mobicents/isup2sip/management/Channel.java Mon Jul 29 10:24:14 2013
@@ -1,8 +1,8 @@
 package org.mobicents.isup2sip.management;

-public class Channel {
+public class Channel{
        public enum State {
-               UNKNOWN, IDLE, USED, BLOCKED, BLOCKREQ
+               UNKNOWN, IDLE, INCO, OUTGO, BLOCKED, BLOCKREQ
        };

        protected State state;
@@ -14,7 +14,7 @@
        protected String endpointId;

        /** ISUP (ea isup-api) cic */
-       int cic; // from isup-api
+       protected int cic; // from isup-api

        public Channel(String gatewayAddr, String endPoint, int isupCic) {
                state = State.UNKNOWN;
=======================================
--- /core/domain/src/main/java/org/mobicents/isup2sip/management/CicManagement.java Mon Jul 29 06:28:57 2013 +++ /core/domain/src/main/java/org/mobicents/isup2sip/management/CicManagement.java Mon Jul 29 10:24:14 2013
@@ -3,52 +3,72 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
+import java.util.Iterator;

 import org.mobicents.isup2sip.management.Channel.State;

 public class CicManagement {
-       private static final Logger logger = 
Logger.getLogger(CicManagement.class
-                       .getName());
+ private static final Logger logger = Logger.getLogger(CicManagement.class.getName());

        private static final Object synchCic = new Object();
protected static Map<Integer, Channel> channelByCic = new HashMap<Integer, Channel>();

-       protected int debug = 1;
-
-       public CicManagement() throws Exception {
+       public CicManagement(String gateway, int part) throws Exception {
                logger.warning("Isup2Sip cic mahagement started");

                channelByCic.clear();
-
-               for (int cic = 1; cic < 16; cic++) {
-                       // Channel ch = new
-                       // 
Channel("192.168.1.18:2427",Integer.toString(cic),cic);
-                       Channel ch = new Channel("192.168.1.18:2427",
-                                       Integer.toString(cic + 32), cic);
+               // TODO: this is for DEBUG only,
+               // real configuration should be read from a file
+ // for testing, half of a card is acting as one equipment, a second as is another
+
+               for (int cic = 1; cic < 31; cic++) {
+                       if(cic == 16) continue;
+                       Channel ch;
+                       if(part!=0)     ch = new 
Channel(gateway,Integer.toString(cic + 32), cic);
+                       else            ch = new 
Channel(gateway,Integer.toString(cic), cic);
                        channelByCic.put(cic, ch);

                        // TODO: in fact, need to reset circuits
-                       setState(cic, State.IDLE);
+                       ch.setState(State.IDLE);
+
+                       logger.warning("created channel " + ch +
+                                       " cic=" + cic + ": " + ch.getCic() + 
"|" +
+                                       ch.getEndpointId() + "|" + 
ch.getGatewayAddress());
                }
        }

        public Channel getIdleChannel() {
-               /*
-                * synchronized(synchCic) { Iterator<Channel> i = null; i =
-                * channelByCic.values().iterator(); while(i.hasNext()){
-                * if(i.next().getState() == State.IDLE) return i.next(); } 
return null;
-                * }
-                */
-               debug++;
-               logger.warning("debugging: value is " + debug);
-               return channelByCic.get(debug);
+               synchronized(synchCic) {
+                       Iterator <Channel> i = null; i = 
channelByCic.values().iterator();
+                       while(i.hasNext()){
+                                       Channel ch = i.next();
+ logger.warning("trying "+ ch + ":" + ch.getCic() + " state=" + ch.getState());
+                                       if(ch.getState() == State.IDLE) {
+
+ logger.warning("allocating cic=" + ch.getCic() + " ep=" + ch.getEndpointId());
+                                                       
ch.setState(State.OUTGO);
+                                                       return ch; }
+ else logger.warning("skipping cic=" + ch.getCic() + " ep=" + ch.getEndpointId());
+                       }
+
+                       return null;
+               }
+       }
+
+       public void setIdle(int cic) {
+               synchronized (synchCic) {
+                       try {
+                               channelByCic.get(cic).setState(State.IDLE);
+                       } catch (Exception e) {

+                       }
+               }
        }

-       public void setState(int cic, Channel.State state) {
+       public void setBusy(int cic) {
                synchronized (synchCic) {
                        try {
-                               channelByCic.get(cic).setState(state);
+                               channelByCic.get(cic).setState(State.INCO);
                        } catch (Exception e) {

                        }
=======================================
--- /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipManagement.java Mon Jul 29 06:28:57 2013 +++ /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipManagement.java Mon Jul 29 10:24:14 2013
@@ -43,7 +43,13 @@
        private Isup2SipPropertiesManagement servicePropertiesManagement = null;

        private MBeanServer mbeanServer = null;
+
+       private String gatewayForDebug = null;
+
+       private int gatewayPartForDebug = 0;

+       private int remoteSPC = 0;
+
        public Isup2SipManagement(String name) {
                this.name = name;
        }
@@ -59,12 +65,26 @@
        public void setPersistDir(String persistDir) {
                this.persistDir = persistDir;
        }
+
+       public void setGateway(String gw){
+               this.gatewayForDebug = gw;
+       }

+       public void setGatewayPart(int part){
+               this.gatewayPartForDebug = part;
+       }
+
+       public void setRemoteSPC(int spc){
+               this.remoteSPC = spc;
+       }
+
        public void start() throws Exception {
                this.servicePropertiesManagement = Isup2SipPropertiesManagement
                                .getInstance(this.name);
+
+ logger.info("starting as GW=" + gatewayForDebug + ", part=" + gatewayPartForDebug);
                this.servicePropertiesManagement.setPersistDir(this.persistDir);
-               this.servicePropertiesManagement.start();
+ this.servicePropertiesManagement.start(remoteSPC,gatewayForDebug,gatewayPartForDebug);

                // Register the MBeans
                this.mbeanServer = MBeanServerLocator.locateJBoss();
=======================================
--- /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipPropertiesManagement.java Mon Jul 29 06:28:57 2013 +++ /core/domain/src/main/java/org/mobicents/isup2sip/management/Isup2SipPropertiesManagement.java Mon Jul 29 10:24:14 2013
@@ -63,6 +63,8 @@

        private CicManagement cicManagement;

+       private int remoteSPC;
+
        private Isup2SipPropertiesManagement(String name) {
                this.name = name;
                binding.setClassAttribute(CLASS_ATTRIBUTE);
@@ -86,6 +88,10 @@
        public CicManagement getCicManagement() {
                return cicManagement;
        }
+
+       public int getRemoteSPC(){
+               return this.remoteSPC;
+       }

        @Override
        public String getPersistDir() {
@@ -96,9 +102,10 @@
                this.persistDir = persistDir;
        }

-       public void start() throws Exception {
+       public void start(int remotePC, String gw, int part) throws Exception {

                this.persistFile.clear();
+               this.remoteSPC = remotePC;

                if (persistDir != null) {
                        
this.persistFile.append(persistDir).append(File.separator)
@@ -125,7 +132,7 @@

                // this.setUpDataSource();

-               this.cicManagement = new CicManagement();
+               this.cicManagement = new CicManagement(gw, part);

        }

=======================================
--- /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/Isup2SipSbb.java Mon Jul 29 06:28:57 2013 +++ /core/slee/sbbs/src/main/java/org/mobicents/isup2sip/sbb/Isup2SipSbb.java Mon Jul 29 10:24:14 2013
@@ -21,6 +21,7 @@
  */

 package org.mobicents.isup2sip.sbb;
+
 import jain.protocol.ip.mgcp.JainMgcpEvent;
 import jain.protocol.ip.mgcp.message.CreateConnection;
 import jain.protocol.ip.mgcp.message.CreateConnectionResponse;
@@ -43,9 +44,13 @@
 import javax.sip.ResponseEvent;
 import javax.sip.ServerTransaction;
 import javax.sip.SipException;
+import javax.sip.address.SipURI;
+import javax.sip.address.URI;
 import javax.sip.header.CSeqHeader;
 import javax.sip.header.ContentTypeHeader;
+import javax.sip.header.FromHeader;
 import javax.sip.header.HeaderFactory;
+import javax.sip.header.ToHeader;
 import javax.sip.message.MessageFactory;
 import javax.sip.message.Request;
 import javax.sip.message.Response;
@@ -68,18 +73,24 @@
 import org.mobicents.isup2sip.management.Channel;
 import org.mobicents.isup2sip.management.CicManagement;
 import org.mobicents.isup2sip.management.Isup2SipPropertiesManagement;
+//import org.mobicents.isup2sip.sbb.CauseCodeMapping;
+import org.mobicents.isup2sip.sbb.CodingShemes;
 import org.mobicents.protocols.ss7.isup.ISUPMessageFactory;
 import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
 import org.mobicents.protocols.ss7.isup.message.InitialAddressMessage;
import org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber; import org.mobicents.protocols.ss7.isup.message.parameter.CallingPartyCategory; +import org.mobicents.protocols.ss7.isup.message.parameter.CallingPartyNumber; import org.mobicents.protocols.ss7.isup.message.parameter.CircuitIdentificationCode; import org.mobicents.protocols.ss7.isup.message.parameter.ForwardCallIndicators; import org.mobicents.protocols.ss7.isup.message.parameter.NatureOfConnectionIndicators; import org.mobicents.protocols.ss7.isup.message.parameter.TransmissionMediumRequirement;
 import org.mobicents.slee.resources.ss7.isup.ratype.RAISUPProvider;

-
+/**
+ *
+ * @author dmitri soloviev
+ */
 public abstract class Isup2SipSbb implements javax.slee.Sbb {
        private SbbContext sbbContext;
        private static Tracer tracer;
@@ -91,8 +102,6 @@
        //private AddressFactory addressFactory;
        private MessageFactory messageFactory;

-       private RequestEvent sipEvent;
-
        // MGCP
        private JainMgcpProvider mgcpProvider;
private MgcpActivityContextInterfaceFactory mgcpActivityContestInterfaceFactory;
@@ -107,36 +116,41 @@
                Isup2SipPropertiesManagement.getInstance();

private final CicManagement cicManagement = isup2SipPropertiesManagement.getCicManagement();
+
+ private final int remoteSPC = isup2SipPropertiesManagement.getRemoteSPC();

+    public Isup2SipSbb(){ }
+
        // Initial request
- public void onInviteEvent(RequestEvent event, ActivityContextInterface aci) {
-               sipEvent = event;
+ public void onInviteEvent(RequestEvent sipEvent, ActivityContextInterface aci) {
+               this.setSipEvent(sipEvent);

+               //tracer.debug("Invite event");
                // ACI is the server transaction activity
                try {
                        // try to allocate CIC
-                       final Channel channel  = getIdleChannel();
+                       final Channel channel = cicManagement.getIdleChannel();
                        if(channel == null) {
-                               tracer.warning("Failed to allocate CIC");
-                               sipReplyToRequestEvent(event, 
Response.SERVICE_UNAVAILABLE);
+                               tracer.warning("Failed to allocate CIC for 
Invite");
+                               sipReplyToRequestEvent(sipEvent, 
Response.SERVICE_UNAVAILABLE);
                                return;
                        }
-                       tracer.info("CIC allocated");
- tracer.info(channel.getEndpointId() +" | " + channel.getCic() + " | " + channel.getGatewayAddress());
+
+                       this.setCicValue(channel.getCic());
+
                        // Create SIP dialog
- final DialogActivity sipDialog = (DialogActivity) sipProvider.getNewDialog(event.getServerTransaction());
-                       // Obtain the dialog activity context and attach to it
+ final DialogActivity sipDialog = (DialogActivity) sipProvider.getNewDialog(sipEvent.getServerTransaction()); final ActivityContextInterface sipDialogACI = sipActivityContextInterfaceFactory.getActivityContextInterface(sipDialog);
                        final SbbLocalObject sbbLocalObject = 
sbbContext.getSbbLocalObject();
                        sipDialogACI.attach(sbbLocalObject);

                        // send "trying" response
-                       sipReplyToRequestEvent(event, Response.TRYING);
-                       String sdp = new 
String(event.getRequest().getRawContent());
-
-                       CallIdentifier mgcpCallID = 
this.mgcpProvider.getUniqueCallIdentifier();
-//                     setCallIdentifier(mgcpCallID);
-
+                       sipReplyToRequestEvent(sipEvent, Response.TRYING);
+
+                       String sdp = new 
String(sipEvent.getRequest().getRawContent());
+
+                       CallIdentifier mgcpCallID = 
mgcpProvider.getUniqueCallIdentifier();
+                       this.setMgcpCallIdentifier(mgcpCallID.toString());
EndpointIdentifier endpointID = new EndpointIdentifier(channel.getEndpointId(),channel.getGatewayAddress());
                        CreateConnection createConnection = new 
CreateConnection(this,
                                        mgcpCallID, endpointID, 
ConnectionMode.SendRecv);
@@ -148,13 +162,12 @@
                        }
                        int txID = mgcpProvider.getUniqueTransactionHandler();
                        createConnection.setTransactionHandle(txID);
-
+
                        MgcpConnectionActivity connectionActivity = null;
                        try {
connectionActivity = mgcpProvider.getConnectionActivity(txID, endpointID); ActivityContextInterface epnAci = mgcpActivityContestInterfaceFactory.getActivityContextInterface(connectionActivity);
                                epnAci.attach(sbbLocalObject);
-
                        } catch (FactoryException ex) {
                                ex.printStackTrace();
                        } catch (NullPointerException ex) {
@@ -162,44 +175,22 @@
                        } catch (UnrecognizedActivityException ex) {
                                ex.printStackTrace();
                        }
-
-                       mgcpProvider.sendMgcpEvents(new JainMgcpEvent[] { 
createConnection });
-                       tracer.info("SIP->ISUP, CRCX sent");

+                       mgcpProvider.sendMgcpEvents(new JainMgcpEvent[] { 
createConnection });
+ tracer.info("SIP->ISUP, CRCX sent; ep ID=" + endpointID + " sbb=" + sbbLocalObject);
+
                        // with a proper CRCX_RESP, sent IAM..
-/*
-                       // issue IAM
-                       IsupProvider isupProvider =
- InitialAddressMessage msg = super.provider.getMessageFactory().createIAM(1); - NatureOfConnectionIndicators nai = super.provider.getParameterFactory().createNatureOfConnectionIndicators(); - ForwardCallIndicators fci = super.provider.getParameterFactory().createForwardCallIndicators(); - CallingPartyCategory cpg = super.provider.getParameterFactory().createCallingPartyCategory(); - TransmissionMediumRequirement tmr = super.provider.getParameterFactory().createTransmissionMediumRequirement(); - CalledPartyNumber cpn = super.provider.getParameterFactory().createCalledPartyNumber();
-            cpn.setAddress("14614577");
-
-
-            msg.setNatureOfConnectionIndicators(nai);
-            msg.setForwardCallIndicators(fci);
-            msg.setCallingPartCategory(cpg);
-            msg.setCalledPartyNumber(cpn);
-            msg.setTransmissionMediumRequirement(tmr);
-                       // send CRCX
-*/

                } catch (Throwable e) {
                        tracer.severe("Failed to process incoming INVITE.", e);
-                       sipReplyToRequestEvent(event, 
Response.SERVICE_UNAVAILABLE);
+                       sipReplyToRequestEvent(sipEvent, 
Response.SERVICE_UNAVAILABLE);
                }
        }
-       private Channel getIdleChannel() {
-               // TODO Auto-generated method stub
-               return null;
-       }
+
        public void onCreateConnectionResponse(CreateConnectionResponse event,
                        ActivityContextInterface aci) {
-               tracer.info("Receive CRCX response: " + event);
-
+               tracer.info("CRCX RESP sbb=" + sbbContext.getSbbLocalObject());
+
                ReturnCode status = event.getReturnCode();

boolean connectionCreated = (status.getValue() == ReturnCode.TRANSACTION_EXECUTED_NORMALLY);
@@ -221,22 +212,30 @@

                        Response response = null;
                        try {
- response = messageFactory.createResponse(Response.SESSION_PROGRESS, sipEvent.getRequest(), contentType, sdp.getBytes()); + response = messageFactory.createResponse(Response.SESSION_PROGRESS, getSipEvent().getRequest(), contentType, sdp.getBytes());
                        } catch (ParseException ex) {
tracer.warning("ParseException while trying to create SESSION_PROGRESS Response", ex);
                        }

-                       InitialAddressMessage msg = 
isupMessageFactory.createIAM(1);
+                       // fetch A- and B- numbers
+                       Request sipRequest = this.getSipEvent().getRequest();
+ FromHeader fromHeader = (FromHeader) sipRequest.getHeader(FromHeader.NAME);
+                       ToHeader toHeader = (ToHeader) 
sipRequest.getHeader(ToHeader.NAME);
+ final String aNumber = CodingShemes.numberFromURI(fromHeader.getAddress().getURI().toString()); + final String bNumber = CodingShemes.numberFromURI(toHeader.getAddress().getURI().toString());
+                       tracer.warning("To   header=" + toHeader + " ->" + 
bNumber);
+                       tracer.warning("From header=" + fromHeader + " ->" + 
aNumber);
+
+ InitialAddressMessage msg = isupMessageFactory.createIAM(this.getCicValue()); CircuitIdentificationCode cic = isupParameterFactory.createCircuitIdentificationCode();
-                       cic.setCIC(2);
NatureOfConnectionIndicators nai = isupParameterFactory.createNatureOfConnectionIndicators(); ForwardCallIndicators fci = isupParameterFactory.createForwardCallIndicators(); CallingPartyCategory cpg = isupParameterFactory.createCallingPartyCategory(); TransmissionMediumRequirement tmr = isupParameterFactory.createTransmissionMediumRequirement(); CalledPartyNumber cpn = isupParameterFactory.createCalledPartyNumber();
-            cpn.setAddress("14614577");
-
-            msg.setCircuitIdentificationCode(cic);
+ CallingPartyNumber cgp = isupParameterFactory.createCallingPartyNumber();
+            cpn.setAddress(bNumber);
+            cgp.setAddress(aNumber);
             msg.setNatureOfConnectionIndicators(nai);
             msg.setForwardCallIndicators(fci);
             msg.setCallingPartCategory(cpg);
@@ -244,70 +243,15 @@
             msg.setTransmissionMediumRequirement(tmr);

             try {
-               //Context ctx = isupProvider.createClientTransaction(msg);
- //ActivityContextInterface circuitACI = isupActivityContextInterfaceFactory.getActivityContextInterface();
-                //circuitACI.attach(this.sbbContext.getSbbLocalObject());
-                //ctx.sendRequest();
-                isupProvider.sendMessage(msg,222);
+                isupProvider.sendMessage(msg,remoteSPC);

                 } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
             }

-            /*
-             *
-             *         private void resetCircuits() {
-                ActivityContextInterface circuitACI = null;
-                ISUPClientTransaction ctx = null;
-
- ISUPMessageFactory msgFactory = this.provider.getMessageFactory(); - ISUPParameterFactory prmFactory = this.provider.getParameterFactory();
-
-                for (int i = 1; i <= 10; i++) {
-                        ResetCircuitMessage rst = null;
-
-                        rst = msgFactory.createRSC();
- CircuitIdentificationCode cic = prmFactory.createCircuitIdentificationCode();
-                        cic.setCIC(i);
-                        rst.setCircuitIdentificationCode(cic);
-                        try {
- ctx = this.provider.createClientTransaction(rst); - circuitACI = this.acif.getActivityContextInterface(ctx); - circuitACI.attach(this.sbbContext.getSbbLocalObject());
-                                ctx.sendRequest();
-                        } catch (ActivityAlreadyExistsException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (IllegalArgumentException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (NullPointerException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (IllegalStateException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (SLEEException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (TransactionAlredyExistsException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (StartActivityException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (ParameterRangeInvalidException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        } catch (IOException e) {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                        }
-                }
-             */
                        try {
-                               
sipEvent.getServerTransaction().sendResponse(response);
+                               
getSipEvent().getServerTransaction().sendResponse(response);
                        } catch (InvalidArgumentException ex) {
tracer.warning("InvalidArgumentException while trying to send SESSION_PROGRESS Response (with sdp)", ex);
                        } catch (SipException ex) {
@@ -316,12 +260,15 @@
                }
                else {
                        /* unable to create voice path (that's strange), so
+                        * mark CIC as IDLE
                         * SIP: send SERVICE_UNAVAILABLE
-                        * detach MGCP
+//!!!!!!!       * detach MGCP
                         */
+                       cicManagement.setIdle(this.getCicValue());
+
                        try {
- Response response = messageFactory.createResponse(Response.SERVER_INTERNAL_ERROR, sipEvent.getRequest());
-                               
sipEvent.getServerTransaction().sendResponse(response);
+ Response response = messageFactory.createResponse(Response.SERVER_INTERNAL_ERROR, getSipEvent().getRequest());
+                               
getSipEvent().getServerTransaction().sendResponse(response);
                        } catch (Exception ex) {
tracer.warning("Exception while trying to send SERVER_INTERNAL_ERROR Response", ex);
                        }
@@ -360,10 +307,7 @@
        }

        public void onBye(RequestEvent event, ActivityContextInterface aci) {
-               // send back 200 ok for this dialog right away, to avoid 
retransmissions
-               sipReplyToRequestEvent(event, Response.OK);
-               // forward to the other dialog
-               processMidDialogRequest(event, aci);
+
        }

public void onCancel(CancelRequestEvent event, ActivityContextInterface aci) {
@@ -372,16 +316,7 @@
                }

                try {
-                       this.sipProvider.acceptCancel(event, false);
-                       final ActivityContextInterface peerDialogACI = 
getPeerDialog(aci);
-                       final DialogActivity peerDialog = (DialogActivity) 
peerDialogACI
-                                       .getActivity();
-                       final DialogState peerDialogState = 
peerDialog.getState();
-                       if (peerDialogState == null || peerDialogState == 
DialogState.EARLY) {
-                               peerDialog.sendCancel();
-                       } else {
-                               
peerDialog.sendRequest(peerDialog.createRequest(Request.BYE));
-                       }
+
                } catch (Exception e) {
                        tracer.severe("Failed to process cancel request", e);
                }
@@ -399,101 +334,34 @@
                        tracer.severe("Failed to reply to request event:\n" + 
event, e);
                }
        }
-
-       private void processMidDialogRequest(RequestEvent event,
-                       ActivityContextInterface dialogACI) {
-               try {
-                       // Find the dialog to forward the request on
-                       ActivityContextInterface peerACI = 
getPeerDialog(dialogACI);
-                       forwardRequest(event,
-                                       (DialogActivity) peerACI.getActivity());
-               } catch (SipException e) {
-                       tracer.severe(e.getMessage(), e);
-                       sipReplyToRequestEvent(event, 
Response.SERVICE_UNAVAILABLE);
-               }
-       }

        private void processResponse(ResponseEvent event,
                        ActivityContextInterface aci) {
                try {
-                       // Find the dialog to forward the response on
-                       ActivityContextInterface peerACI = getPeerDialog(aci);
-                       forwardResponse((DialogActivity) aci.getActivity(),
-                                       (DialogActivity) peerACI.getActivity(), 
event
-                                                       
.getClientTransaction(), event.getResponse());
-               } catch (SipException e) {
+
+               } catch (Exception e) {
                        tracer.severe(e.getMessage(), e);
                }
        }
+
+
+
+       public abstract void setCicValue(int cicValue);

- private ActivityContextInterface getPeerDialog(ActivityContextInterface aci)
-                       throws SipException {
-               final ActivityContextInterface incomingDialogAci = 
getIncomingDialog();
-               if (aci.equals(incomingDialogAci)) {
-                       return getOutgoingDialog();
-               }
-               if (aci.equals(getOutgoingDialog())) {
-                       return incomingDialogAci;
-               }
-               throw new SipException("could not find peer dialog");
+       public abstract int getCicValue();

-       }
+       public abstract void setSipEvent(RequestEvent sipEvent);

-       private void forwardRequest(RequestEvent event, DialogActivity out)
-                       throws SipException {
-               final Request incomingRequest = event.getRequest();
-               if (tracer.isInfoEnabled()) {
-                       tracer.info("Forwarding request " + 
incomingRequest.getMethod()
-                                       + " to dialog " + out);
-               }
-               // Copies the request, setting the appropriate headers for the 
dialog.
-               Request outgoingRequest = out.createRequest(incomingRequest);
-               // Send the request on the dialog activity
-               final ClientTransaction ct = out.sendRequest(outgoingRequest);
-               // Record an association with the original server transaction,
-               // so we can retrieve it when forwarding the response.
-               out.associateServerTransaction(ct, 
event.getServerTransaction());
-       }
-
-       private void forwardResponse(DialogActivity in, DialogActivity out,
-                       ClientTransaction ct, Response receivedResponse)
-                       throws SipException {
-               // Find the original server transaction that this response
-               // should be forwarded on.
-               final ServerTransaction st = 
in.getAssociatedServerTransaction(ct);
-               // could be null
-               if (st == null)
-                       throw new SipException(
-                                       "could not find associated server 
transaction");
-               if (tracer.isInfoEnabled()) {
-                       tracer.info("Forwarding response "
-                                       + receivedResponse.getStatusCode() + " to 
dialog " + out);
-               }
-               // Copy the response across, setting the appropriate headers 
for the
-               // dialog
-               final Response outgoingResponse = out.createResponse(st,
-                               receivedResponse);
-               // Forward response upstream.
-               try {
-                       st.sendResponse(outgoingResponse);
-               } catch (InvalidArgumentException e) {
-                       tracer.severe("Failed to send response:\n" + 
outgoingResponse, e);
-                       throw new SipException("invalid response", e);
-               }
-       }
-
-       // other request handling methods
-       // lifecycle methods
-       // CMP field accessors for each Dialogs ACI
-       public abstract void setIncomingDialog(ActivityContextInterface aci);
-
-       public abstract ActivityContextInterface getIncomingDialog();
-
-       public abstract void setOutgoingDialog(ActivityContextInterface aci);
-
-       public abstract ActivityContextInterface getOutgoingDialog();
-
+       public abstract RequestEvent getSipEvent();

+       public abstract void setMgcpCallIdentifier(String mgcpCallId);
+
+       public abstract String getMgcpCallIdentifier();
+
+       public abstract void setMgcpConnectionIdentifier(String mgcpConnId);
+
+       public abstract String getMgcpConnectionIdentifier();
+

        public void setSbbContext(SbbContext context) {
                this.sbbContext = context;
@@ -529,9 +397,11 @@



-
-
-
+       public void showMe(){
+               tracer.warning("object: " + sbbContext.getSbbLocalObject()
+                               + " cic=" + this.getCicValue()
+                               + " sipEvent=" + this.getSipEvent());
+       }



=======================================
--- /core/slee/sbbs/src/main/resources/META-INF/sbb-jar.xml Mon Jul 29 06:28:57 2013 +++ /core/slee/sbbs/src/main/resources/META-INF/sbb-jar.xml Mon Jul 29 10:24:14 2013
@@ -11,10 +11,16 @@
                        <sbb-abstract-class reentrant="True">
<sbb-abstract-class-name>org.mobicents.isup2sip.sbb.Isup2SipSbb</sbb-abstract-class-name>
                                <cmp-field>
-                                       
<cmp-field-name>incomingDialog</cmp-field-name>
+                                       
<cmp-field-name>sipEvent</cmp-field-name>
                                </cmp-field>
                                <cmp-field>
-                                       
<cmp-field-name>outgoingDialog</cmp-field-name>
+                                       
<cmp-field-name>cicValue</cmp-field-name>
+                               </cmp-field>
+                               <cmp-field>
+                                       
<cmp-field-name>mgcpCallIdentifier</cmp-field-name>
+                               </cmp-field>
+                               <cmp-field>
+                                       
<cmp-field-name>mgcpConnectionIdentifier</cmp-field-name>
                                </cmp-field>
                        </sbb-abstract-class>
                </sbb-classes>

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to