72 *
73 * <h3> The Scope of a Multicast Address </h3>
74 *
75 * Historically the IPv4 TTL field in the IP header has doubled as a
76 * multicast scope field: a TTL of 0 means node-local, 1 means
77 * link-local, up through 32 means site-local, up through 64 means
78 * region-local, up through 128 means continent-local, and up through
79 * 255 are global. However, the administrative scoping is preferred.
80 * Please refer to <a href="http://www.ietf.org/rfc/rfc2365.txt">
81 * <i>RFC 2365: Administratively Scoped IP Multicast</i></a>
82 * @since 1.4
83 */
84
85 public final
86 class Inet4Address extends InetAddress {
87 static final int INADDRSZ = 4;
88
89 /** use serialVersionUID from InetAddress, but Inet4Address instance
90 * is always replaced by an InetAddress instance before being
91 * serialized */
92 private static final long serialVersionUID = 3286316764910316507L;
93
94 /*
95 * Perform initializations.
96 */
97 static {
98 init();
99 }
100
101 Inet4Address() {
102 super();
103 holder().hostName = null;
104 holder().address = 0;
105 holder().family = IPv4;
106 }
107
108 Inet4Address(String hostName, byte addr[]) {
109 holder().hostName = hostName;
110 holder().family = IPv4;
111 if (addr != null) {
117 holder().address = address;
118 }
119 }
120 holder().originalHostName = hostName;
121 }
122 Inet4Address(String hostName, int address) {
123 holder().hostName = hostName;
124 holder().family = IPv4;
125 holder().address = address;
126 holder().originalHostName = hostName;
127 }
128
129 /**
130 * Replaces the object to be serialized with an InetAddress object.
131 *
132 * @return the alternate object to be serialized.
133 *
134 * @throws ObjectStreamException if a new object replacing this
135 * object could not be created
136 */
137 private Object writeReplace() throws ObjectStreamException {
138 // will replace the to be serialized 'this' object
139 InetAddress inet = new InetAddress();
140 inet.holder().hostName = holder().getHostName();
141 inet.holder().address = holder().getAddress();
142
143 /**
144 * Prior to 1.4 an InetAddress was created with a family
145 * based on the platform AF_INET value (usually 2).
146 * For compatibility reasons we must therefore write
147 * the InetAddress with this family.
148 */
149 inet.holder().family = 2;
150
151 return inet;
152 }
153
154 /**
155 * Utility routine to check if the InetAddress is an
156 * IP multicast address. IP multicast address is a Class D
|
72 *
73 * <h3> The Scope of a Multicast Address </h3>
74 *
75 * Historically the IPv4 TTL field in the IP header has doubled as a
76 * multicast scope field: a TTL of 0 means node-local, 1 means
77 * link-local, up through 32 means site-local, up through 64 means
78 * region-local, up through 128 means continent-local, and up through
79 * 255 are global. However, the administrative scoping is preferred.
80 * Please refer to <a href="http://www.ietf.org/rfc/rfc2365.txt">
81 * <i>RFC 2365: Administratively Scoped IP Multicast</i></a>
82 * @since 1.4
83 */
84
85 public final
86 class Inet4Address extends InetAddress {
87 static final int INADDRSZ = 4;
88
89 /** use serialVersionUID from InetAddress, but Inet4Address instance
90 * is always replaced by an InetAddress instance before being
91 * serialized */
92 @java.io.Serial
93 private static final long serialVersionUID = 3286316764910316507L;
94
95 /*
96 * Perform initializations.
97 */
98 static {
99 init();
100 }
101
102 Inet4Address() {
103 super();
104 holder().hostName = null;
105 holder().address = 0;
106 holder().family = IPv4;
107 }
108
109 Inet4Address(String hostName, byte addr[]) {
110 holder().hostName = hostName;
111 holder().family = IPv4;
112 if (addr != null) {
118 holder().address = address;
119 }
120 }
121 holder().originalHostName = hostName;
122 }
123 Inet4Address(String hostName, int address) {
124 holder().hostName = hostName;
125 holder().family = IPv4;
126 holder().address = address;
127 holder().originalHostName = hostName;
128 }
129
130 /**
131 * Replaces the object to be serialized with an InetAddress object.
132 *
133 * @return the alternate object to be serialized.
134 *
135 * @throws ObjectStreamException if a new object replacing this
136 * object could not be created
137 */
138 @java.io.Serial
139 private Object writeReplace() throws ObjectStreamException {
140 // will replace the to be serialized 'this' object
141 InetAddress inet = new InetAddress();
142 inet.holder().hostName = holder().getHostName();
143 inet.holder().address = holder().getAddress();
144
145 /**
146 * Prior to 1.4 an InetAddress was created with a family
147 * based on the platform AF_INET value (usually 2).
148 * For compatibility reasons we must therefore write
149 * the InetAddress with this family.
150 */
151 inet.holder().family = 2;
152
153 return inet;
154 }
155
156 /**
157 * Utility routine to check if the InetAddress is an
158 * IP multicast address. IP multicast address is a Class D
|