Commit 8103c6d8 authored by jehan's avatar jehan

debug sip proxy

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@111 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 63ff2735
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-cdt version="2.0"?>
<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
<data>
<item id="org.eclipse.cdt.core.pathentry">
<pathentry kind="src" path=""/>
<pathentry kind="out" path=""/>
<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
</item>
</data>
</cdtproject>
......@@ -61,6 +61,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
private static Configurator mConfigurator;
private static String mConfigHomeDir;
static private boolean mExit = false;
static private boolean isReady = false;
static {
......@@ -279,7 +280,7 @@ public class P2pProxyMain implements P2pProxyMainMBean {
mLog.warn("p2pproxy initilized");
isReady = true;
while (mExit == false) {
Thread.sleep(1000);
}
......@@ -412,9 +413,9 @@ public static void staticLoadTraceConfigFile() throws P2pProxyException {
private static void isReady() throws P2pProxyNotReadyException {
try {
if ((mJxtaNetworkManager!=null && mJxtaNetworkManager.isConnectedToRendezVous(0) == true)
if ((isReady == true && mJxtaNetworkManager.isConnectedToRendezVous(0) == true)
||
(mJxtaNetworkManager!=null && mJxtaNetworkManager.getPeerGroup().getRendezVousService().isRendezVous())) {
(isReady == true && mJxtaNetworkManager.getPeerGroup().getRendezVousService().isRendezVous())) {
//nop connected
} else {
if (mJxtaNetworkManager != null ) {
......
......@@ -299,7 +299,8 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
if (mP2pProxyAccountManagement.isValidAccount(lFromName)) {
lRegistration = new Registration(lFromName);
lRegistration.Contact = aMessage.getContactHeader().getNameAddress().getAddress().toString();;
// forgot contact, use rport lRegistration.Contact = aMessage.getContactHeader().getNameAddress().getAddress().toString();;
updateRegistration(lRegistration,aMessage);
mRegistrationTab.put(lFromName, lRegistration);
} else {
......@@ -325,7 +326,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
if (aRegistrationMessage.getExpiresHeader() != null ) {
aRegistration.Expiration = aRegistrationMessage.getExpiresHeader().getDeltaSeconds()*1000;
}
aRegistration.Contact = "sip:"+aRegistrationMessage.getRemoteAddress()+":"+aRegistrationMessage.getRemotePort();
mSuperPeerProxy.updateRegistration(aRegistration, aRegistrationMessage);
}
......
......@@ -58,8 +58,7 @@ public class SuperPeerProxy implements SipProxy, RegistrationHandler {
if (mLog.isDebugEnabled()) mLog.debug("processing request " +aMessage);
String lTo = aMessage.getToHeader().getNameAddress().getAddress().toString();
SipURL lNextHope = null;
//check if invite
if (aMessage.isInvite() || aMessage.isCancel()) {
//ok need to find the root
//is local ?
synchronized (mRegistrationTab) {
......@@ -70,11 +69,14 @@ public class SuperPeerProxy implements SipProxy, RegistrationHandler {
throw new P2pProxyUserNotFoundException("user ["+lTo+"] not found");
}
}
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
if (aMessage.isInvite() || aMessage.isCancel()) {
//check if invite
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
}
} else {
if (lNextHope == null) {
// not for us
//just look at route set
MultipleHeader lMultipleRoute = aMessage.getRoutes();
......@@ -82,7 +84,8 @@ public class SuperPeerProxy implements SipProxy, RegistrationHandler {
lNextHope = ((RecordRouteHeader)lMultipleRoute.getTop()).getNameAddress().getAddress();
} else {
// last proxy, get route from request uri
lNextHope = aMessage.getRequestLine().getAddress();
//check if we know the user
lNextHope = aMessage.getRequestLine().getAddress();
}
}
......
......@@ -141,7 +141,7 @@ public class SipClient {
String lCallerUri = mSipIdentity;
String lCalleeUri = aTo;
mLog.info("Calling ["+aTo+"] from ["+mSipIdentity+"]");
long lTimout = 75000;
long lTimout = 30000;
final Semaphore lCallerSemaphoreAccepted = new Semaphore(0);
final Semaphore lCalleeSemaphoreClosed = new Semaphore(0);
......@@ -218,7 +218,7 @@ public class SipClient {
String lCallerUri = mSipIdentity;
String lCalleeUri = aTo;
mLog.info("Calling ["+aTo+"] from ["+mSipIdentity+"]");
long lTimout = 75000;
long lTimout = 30000;
final Semaphore lCallerSemaphoreAccepted = new Semaphore(0);
final Semaphore lCalleeSemaphoreClosed = new Semaphore(0);
......@@ -228,12 +228,13 @@ public class SipClient {
lCallerSemaphoreAccepted.release();
call.ackWithAnswer(sdp);
}
public void onCallClosing(Call call, Message bye) {
//nop
}
public void onCallRinging(Call call, Message resp) {
lCallerSemaphoreRinging.release();
}
public void onCallClosed(Call call, Message resp) {
lCalleeSemaphoreClosed.release();
}
};
Call lCaller = new Call(mProvider, lCallerUri, getContact(mProvider), lCallerListener);
if (enableSdp) {
......@@ -250,8 +251,8 @@ public class SipClient {
}
lCaller.bye();
Assert.assertTrue("caller call not closed until ["+lTimout+"]", lCalleeSemaphoreClosed.tryAcquire(lTimout,TimeUnit.MILLISECONDS));
Assert.assertTrue("caller call not closed until ["+aCallDuration + aCallDuration/10+"]", lCalleeSemaphoreClosed.tryAcquire(aCallDuration + aCallDuration/10,TimeUnit.MILLISECONDS));
mLog.info("Call ok");
return lCaller;
} catch (Exception e) {
......@@ -271,9 +272,9 @@ public class SipClient {
public void onCallIncoming(Call call, NameAddress callee, NameAddress caller, String sdp, Message invite) {
call.accept(sdp);
}
public void onCallClosed(Call call, Message resp) {
//nop
}
public void onCallClosing(Call call, Message bye) {
//nop
}
};
Call lCallee = new Call(mProvider, mSipIdentity, getContact(mProvider), lCalleeListener);
lCallee.setLocalSessionDescriptor(sdp_offer);
......
......@@ -22,6 +22,7 @@ package org.linphone.p2pproxy.test.utils;
import java.io.File;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.URI;
import java.util.Timer;
import java.util.TimerTask;
......@@ -75,26 +76,27 @@ public UserInstance(final String userName) throws P2pProxyException {
SipStack.log_path = "userinstance-"+lUserNameUri.getUserInfo()+"/logs";
File lFile = new File(SipStack.log_path);
if (lFile.exists() == false) lFile.mkdir();
mProvider=new SipProvider(null,lSipPort);
//InetAddress[] lAddresses = InetAddress.getAllByName("localhost");
mProvider=new SipProvider(null,lSipPort);
mSipClient = new SipClient(mProvider,userName,30000);
class RegistrarTimerTask extends TimerTask {
@Override
public void run() {
try {
// 1 get proxy address
String lProxyUri = P2pProxyMain.lookupSipProxyUri(P2pProxyResourceManagement.DOMAINE);
URI lProxyUri = URI.create(P2pProxyMain.lookupSipProxyUri(P2pProxyResourceManagement.DOMAINE));
if (lProxyUri == null) {
System.out.println("cannot find registrar");
return;
}
//2 setOutbound proxy
mProvider.setOutboundProxy(new SocketAddress(lProxyUri));
mProvider.setOutboundProxy(new SocketAddress(lProxyUri.getRawSchemeSpecificPart()));
mSipClient.register(REGISTRATION_PERIOD,userName);
mIsRegistered = true;
} catch(Exception e) {
mLog.error("cannot register user["+userName+"]",e);
} finally {
mTimer.schedule(new RegistrarTimerTask(), REGISTRATION_PERIOD-REGISTRATION_PERIOD/10);
mTimer.schedule(new RegistrarTimerTask(), 1000 *(REGISTRATION_PERIOD-REGISTRATION_PERIOD/10));
}
}
......@@ -110,7 +112,7 @@ public void call(String aTo, int duration) {
}
public static void main(String[] args) throws P2pProxyException {
String lFrom=null, lTo=null;
int lDuration = 10, lLoop=1;
int lDuration = 10, lLoop=0;
for (int i=0; i < args.length; i=i+2) {
String argument = args[i];
if (argument.equals("-from")) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment