1/* 2* Conditions Of Use 3* 4* This software was developed by employees of the National Institute of 5* Standards and Technology (NIST), an agency of the Federal Government. 6* Pursuant to title 15 Untied States Code Section 105, works of NIST 7* employees are not subject to copyright protection in the United States 8* and are considered to be in the public domain. As a result, a formal 9* license is not needed to use the software. 10* 11* This software is provided by NIST as a service and is expressly 12* provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15* AND DATA ACCURACY. NIST does not warrant or make any representations 16* regarding the use of the software or the results thereof, including but 17* not limited to the correctness, accuracy, reliability or usefulness of 18* the software. 19* 20* Permission to use this software is contingent upon your acceptance 21* of the terms of this agreement 22* 23* . 24* 25*/ 26package gov.nist.javax.sip; 27 28import java.net.InetAddress; 29import java.net.UnknownHostException; 30 31import javax.sip.address.Hop; 32 33import gov.nist.core.net.AddressResolver; 34import gov.nist.javax.sip.stack.HopImpl; 35import gov.nist.javax.sip.stack.MessageProcessor; 36 37/** 38 * This is the default implementation of the AddressResolver. The AddressResolver is a NIST-SIP specific 39 * feature. The address resolover is consulted to convert a Hop into a meaningful address. The default 40 * implementation is a passthrough. It only gets involved in setting the default port. However, you 41 * can register your own AddressResolver implementation 42 * Note that 43 * The RI checks incoming via headers for resolving the sentBy field. If you want to set it to 44 * some address that cannot be resolved you should register an AddressResolver with the stack. 45 * This feature is also useful for DNS SRV lookup which is not implemented by the RI at present. 46 * 47 * @version 1.2 48 * @since 1.2 49 * @see gov.nist.javax.sip.SipStackImpl#setAddressResolver(AddressResolver) 50 * 51 * @author M. Ranganathan 52 * 53 */ 54public class DefaultAddressResolver implements AddressResolver { 55 56 public DefaultAddressResolver() { 57 58 } 59 /* 60 * (non-Javadoc) 61 * @see gov.nist.core.net.AddressResolver#resolveAddress(javax.sip.address.Hop) 62 */ 63 public Hop resolveAddress(Hop inputAddress) { 64 if (inputAddress.getPort() != -1) 65 return inputAddress; 66 else { 67 return new HopImpl(inputAddress.getHost(), 68 MessageProcessor.getDefaultPort(inputAddress.getTransport()),inputAddress.getTransport()); 69 } 70 } 71 72 73 74} 75