Commits work on pair nomination (Section 8.1.1). Work in progress

This commit is contained in:
emcho 2010-05-08 21:38:00 +00:00
parent d30aa3b96f
commit 007d551863
2 changed files with 136 additions and 0 deletions

View File

@ -0,0 +1,72 @@
/*
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
* Maintained by the SIP Communicator community (http://sip-communicator.org).
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package org.ice4j;
import org.ice4j.message.*;
import org.ice4j.stack.*;
/**
* The class is used to dispatch incoming STUN {@link Response}s. Apart from
* the {@link Response} itself this event also carries a reference to the
* {@link Request} that started the corresponding transaction as well as other
* useful things.
*
* @author Emil Ivov
*/
public class StunResponseEvent
extends StunMessageEvent
{
/**
* Serial version UID for this Serializable class.
*/
private static final long serialVersionUID = -1L;
/**
* The original {@link Request} that started the client transaction that
* the {@link Response} carried in this event belongs to.
*/
private final Request request;
/**
* Creates a new instance of this event.
*
* @param rawMessage the crude message we got off the wire.
* @param response the STUN {@link Response} that we've just received.
* @param request the message itself
*/
public StunResponseEvent(RawMessage rawMessage,
Response response,
Request request)
{
super(rawMessage, response);
this.request = request;
}
/**
* Returns the {@link Request} that started the transaction that this
* {@link Response} has just arrived in.
*
* @return the {@link Request} that started the transaction that this
* {@link Response} has just arrived in.
*/
public Request getRequest()
{
return request;
}
/**
* Returns the {@link Response} that has just arrived and that caused this
* event.
*
* @return the {@link Response} that has just arrived and that caused this
* event.
*/
public Response getResponse()
{
return (Response)getMessage();
}
}

View File

@ -0,0 +1,64 @@
/*
* ice4j, the OpenSource Java Solution for NAT and Firewall Traversal.
* Maintained by the SIP Communicator community (http://sip-communicator.org).
*
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package org.ice4j.ice;
import java.net.*;
import org.ice4j.*;
/**
* Peer Reflexive Candidates are candidates whose IP address and port are a
* binding explicitly allocated by a NAT for an agent when it sent a STUN
* Binding request through the NAT to its peer.
* <p>
* Peer Reflexive Candidates are generally allocated by NATs with endpoint
* dependent mapping also known as Symmetric NATs. PeerReflexiveCandidates
* are generally preferred to relayed ones. RFC 5245 explains this with
* better security ... although simply avoiding a relay would probably be
* enough of a reason for many.
*
* @author Emil Ivov
*/
public class PeerReflexiveCandidate
extends LocalCandidate
{
/**
* Creates a <tt>PeerReflexiveCandidate</tt> instance for the specified
* transport address and properties.
*
* @param transportAddress the transport address that this candidate is
* encapsulating.
* @param parentComponent the <tt>Component</tt> that this candidate
* belongs to.
* @param base the base of a peer reflexive candidate base is the local
* candidate of the candidate pair from which the STUN check was sent.
* @param priority the priority of the candidate.
*/
public PeerReflexiveCandidate(TransportAddress transportAddress,
Component parentComponent,
LocalCandidate base,
long priority)
{
super(transportAddress, parentComponent,
CandidateType.PEER_REFLEXIVE_CANDIDATE);
super.setBase(base);
super.priority = priority;
}
/**
* Returns the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>.
*
* @return the <tt>DatagramSocket</tt> associated with this
* <tt>Candidate</tt>
* @see LocalCandidate#getSocket()
*/
public DatagramSocket getSocket()
{
return ((HostCandidate)getBase()).getSocket();
}
}