MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / rdataFromString

Method rdataFromString

src/main/java/core/org/xbill/DNS/APLRecord.java:173–231  ·  view source on GitHub ↗
(Tokenizer st, Name origin)

Source from the content-addressed store, hash-verified

171}
172
173void
174rdataFromString(Tokenizer st, Name origin) throws IOException {
175 elements = new ArrayList(1);
176 while (true) {
177 Tokenizer.Token t = st.get();
178 if (!t.isString())
179 break;
180
181 boolean negative = false;
182 int family = 0;
183 int prefix = 0;
184
185 String s = t.value;
186 int start = 0;
187 if (s.startsWith("!")) {
188 negative = true;
189 start = 1;
190 }
191 int colon = s.indexOf(':', start);
192 if (colon < 0)
193 throw st.exception("invalid address prefix element");
194 int slash = s.indexOf('/', colon);
195 if (slash < 0)
196 throw st.exception("invalid address prefix element");
197
198 String familyString = s.substring(start, colon);
199 String addressString = s.substring(colon + 1, slash);
200 String prefixString = s.substring(slash + 1);
201
202 try {
203 family = Integer.parseInt(familyString);
204 }
205 catch (NumberFormatException e) {
206 throw st.exception("invalid family");
207 }
208 if (family != Address.IPv4 && family != Address.IPv6)
209 throw st.exception("unknown family");
210
211 try {
212 prefix = Integer.parseInt(prefixString);
213 }
214 catch (NumberFormatException e) {
215 throw st.exception("invalid prefix length");
216 }
217
218 if (!validatePrefixLength(family, prefix)) {
219 throw st.exception("invalid prefix length");
220 }
221
222 byte [] bytes = Address.toByteArray(addressString, family);
223 if (bytes == null)
224 throw st.exception("invalid IP address " +
225 addressString);
226
227 InetAddress address = InetAddress.getByAddress(bytes);
228 elements.add(new Element(negative, address, prefix));
229 }
230 st.unget();

Callers

nothing calls this directly

Calls 9

validatePrefixLengthMethod · 0.95
toByteArrayMethod · 0.95
isStringMethod · 0.80
indexOfMethod · 0.80
exceptionMethod · 0.80
getByAddressMethod · 0.80
ungetMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected