1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel.unix;
17
18 import java.net.Inet6Address;
19 import java.net.InetAddress;
20 import java.net.InetSocketAddress;
21 import java.net.UnknownHostException;
22
23
24
25
26
27
28
29 public final class DatagramSocketAddress extends InetSocketAddress {
30 private static final long serialVersionUID = 3094819287843178401L;
31
32
33 private final int receivedAmount;
34 private final DatagramSocketAddress localAddress;
35
36 DatagramSocketAddress(byte[] addr, int scopeId, int port, int receivedAmount, DatagramSocketAddress local)
37 throws UnknownHostException {
38 super(newAddress(addr, scopeId), port);
39 this.receivedAmount = receivedAmount;
40 localAddress = local;
41 }
42
43 public DatagramSocketAddress localAddress() {
44 return localAddress;
45 }
46
47 public int receivedAmount() {
48 return receivedAmount;
49 }
50
51 private static InetAddress newAddress(byte[] bytes, int scopeId) throws UnknownHostException {
52 if (bytes.length == 4) {
53 return InetAddress.getByAddress(bytes);
54 }
55 return Inet6Address.getByAddress(null, bytes, scopeId);
56 }
57 }