Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces(); short i = 0; NetworkInterface nic = NetworkInterface.getByInetAddress(candidate.getAddress().getInetAddress()); while (nics.hasMoreElements()) { NetworkInterface checkNIC = nics.nextElement(); TransportCandidate transportCandidate = new ICECandidate(candidate.getAddress().getInetAddress().getHostAddress(), 1, nicNum, String.valueOf(random.nextInt(Integer.MAX_VALUE)), candidate.getPort(), "1", candidate.getPriority(), iceType); transportCandidate.setLocalIp(candidate.getBase().getAddress().getInetAddress().getHostAddress()); transportCandidate.setPort(getFreePort()); try { LOGGER.fine("Candidate addr: " + candidate.getAddress().getInetAddress() + "|" + candidate.getBase().getAddress().getInetAddress() + " Priority:" + candidate.getPriority());
public boolean equals(Object obj) { if (obj == null) return false; try { byte[] data1 = this.getBytes(); byte[] data2 = ((Address) obj).getBytes(); if ((data1[0] == data2[0]) && (data1[1] == data2[1]) && (data1[2] == data2[2]) && (data1[3] == data2[3])) return true; return false; } catch (UtilityException ue) { return false; } }
public String toString() { return "Address " + address.toString() + ", Port " + port; } }
ma.setAddress(new Address(receive.getAddress().getAddress())); ma.setPort(receive.getPort()); sendMH.addMessageAttribute(ma); ca.setAddress(new Address(changedPortIP.getLocalAddress().getAddress())); ca.setPort(changedPortIP.getLocalPort()); sendMH.addMessageAttribute(ca); sa.setAddress(new Address(changedPort.getLocalAddress().getAddress())); sa.setPort(changedPort.getLocalPort()); sendMH.addMessageAttribute(sa); if (ra != null) { send.setPort(ra.getPort()); send.setAddress(ra.getAddress().getInetAddress()); } else { send.setPort(receive.getPort()); sa.setAddress(new Address(changedIP.getLocalAddress().getAddress())); sa.setPort(changedIP.getLocalPort()); sendMH.addMessageAttribute(sa); if (ra != null) { send.setPort(ra.getPort()); send.setAddress(ra.getAddress().getInetAddress()); } else { send.setPort(receive.getPort()); sa.setAddress(new Address(receiverSocket.getLocalAddress().getAddress()));
public Address getAddress() throws UtilityException { return new Address(socket.getLocalAddress().getAddress()); }
ma.setAddress(new Address(receive.getAddress().getAddress())); ma.setPort(receive.getPort()); sendMH.addMessageAttribute(ma); ca.setAddress(new Address(changedPortIP.getLocalAddress().getAddress())); ca.setPort(changedPortIP.getLocalPort()); sendMH.addMessageAttribute(ca); sa.setAddress(new Address(changedPort.getLocalAddress().getAddress())); sa.setPort(changedPort.getLocalPort()); sendMH.addMessageAttribute(sa); if (ra != null) { send.setPort(ra.getPort()); send.setAddress(ra.getAddress().getInetAddress()); } else { send.setPort(receive.getPort()); sa.setAddress(new Address(changedIP.getLocalAddress().getAddress())); sa.setPort(changedIP.getLocalPort()); sendMH.addMessageAttribute(sa); if (ra != null) { send.setPort(ra.getPort()); send.setAddress(ra.getAddress().getInetAddress()); } else { send.setPort(receive.getPort()); sa.setAddress(new Address(receiverSocket.getLocalAddress().getAddress()));
public Address getAddress() throws UtilityException { return new Address(socket.getLocalAddress().getAddress()); }
public Candidate(Address address, short componentId) throws SocketException, UnknownHostException, UtilityException { this.socket = new DatagramSocket(0, address.getInetAddress()); this.type = CandidateType.Local; this.componentId = componentId; this.priority = 0; this.base = this; this.isInUse = false; }
public MappedResponseChangedSourceAddressReflectedFrom() { super(); try { port = 0; address = new Address("0.0.0.0"); } catch (UtilityException ue) { ue.getMessage(); ue.printStackTrace(); } }
public boolean equals(Object obj) { if (obj == null) return false; try { byte[] data1 = this.getBytes(); byte[] data2 = ((Address) obj).getBytes(); if ((data1[0] == data2[0]) && (data1[1] == data2[1]) && (data1[2] == data2[2]) && (data1[3] == data2[3])) return true; return false; } catch (UtilityException ue) { return false; } }
public String toString() { return "Address " + address.toString() + ", Port " + port; } }
public Candidate(Address address, short componentId) throws SocketException, UnknownHostException, UtilityException { this.socket = new DatagramSocket(0, address.getInetAddress()); this.type = CandidateType.Local; this.componentId = componentId; this.priority = 0; this.base = this; this.isInUse = false; }
public MappedResponseChangedSourceAddressReflectedFrom() { super(); try { port = 0; address = new Address("0.0.0.0"); } catch (UtilityException ue) { ue.getMessage(); ue.printStackTrace(); } }
public byte[] getBytes() throws UtilityException { byte[] result = new byte[12]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(8), 0, result, 2, 2); // mappedaddress header // family result[5] = Utility.integerToOneByte(0x01); // port System.arraycopy(Utility.integerToTwoBytes(port), 0, result, 6, 2); // address System.arraycopy(address.getBytes(), 0, result, 8, 4); return result; }
public Candidate(Address address, CandidateType type, short componentId, Candidate base) throws SocketException, UnknownHostException, UtilityException { this.socket = new DatagramSocket(0, address.getInetAddress()); this.type = type; setComponentId(componentId); this.priority = 0; this.base = base; this.isInUse = false; }
try { Candidate local = new Candidate(new Address(iaddress.getAddress()), componentId); candidates.add(local); DiscoveryInfo di = test.test(); if (di.getPublicIP() != null) { Candidate cand = new Candidate(new Address(di.getPublicIP().getAddress()), CandidateType.ServerReflexive, componentId, local); cand.setComponentId(componentId); candidates.add(cand);
public byte[] getBytes() throws UtilityException { byte[] result = new byte[12]; // message attribute header // type System.arraycopy(Utility.integerToTwoBytes(typeToInteger(type)), 0, result, 0, 2); // length System.arraycopy(Utility.integerToTwoBytes(8), 0, result, 2, 2); // mappedaddress header // family result[5] = Utility.integerToOneByte(0x01); // port System.arraycopy(Utility.integerToTwoBytes(port), 0, result, 6, 2); // address System.arraycopy(address.getBytes(), 0, result, 8, 4); return result; }
public Candidate(Address address, CandidateType type, short componentId, Candidate base) throws SocketException, UnknownHostException, UtilityException { this.socket = new DatagramSocket(0, address.getInetAddress()); this.type = type; setComponentId(componentId); this.priority = 0; this.base = base; this.isInUse = false; }
try { Candidate local = new Candidate(new Address(iaddress.getAddress()), componentId); candidates.add(local); DiscoveryInfo di = test.test(); if (di.getPublicIP() != null) { Candidate cand = new Candidate(new Address(di.getPublicIP().getAddress()), CandidateType.ServerReflexive, componentId, local); cand.setComponentId(componentId); candidates.add(cand);
receiveSocket.connect(ca.getAddress().getInetAddress(), ca.getPort()); receiveSocket.setSoTimeout(timeout);