1 /*
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
507 pkt.putByte(label.charAt(j), off++);
508 }
509 }
510 if (!fqdn.hasRootLabel()) {
511 pkt.putByte(0, off);
512 }
513 }
514
515 //-------------------------------------------------------------------------
516
517 private byte[] lookupResponse(Integer xid) throws NamingException {
518 //
519 // Check the queued responses: some other thread in between
520 // received the response for this request.
521 //
522 if (debug) {
523 dprint("LOOKUP for: " + xid +
524 "\tResponse Q:" + resps);
525 }
526 byte[] pkt;
527 if ((pkt = (byte[]) resps.get(xid)) != null) {
528 checkResponseCode(new Header(pkt, pkt.length));
529 synchronized (queuesLock) {
530 resps.remove(xid);
531 reqs.remove(xid);
532 }
533
534 if (debug) {
535 dprint("FOUND (" + Thread.currentThread() +
536 ") for:" + xid);
537 }
538 }
539 return pkt;
540 }
541
542 /*
543 * Checks the header of an incoming DNS response.
544 * Returns true if it matches the given xid and throws a naming
545 * exception, if appropriate, based on the response code.
546 */
547 private boolean isMatchResponse(byte[] pkt, int xid)
|
1 /*
2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
507 pkt.putByte(label.charAt(j), off++);
508 }
509 }
510 if (!fqdn.hasRootLabel()) {
511 pkt.putByte(0, off);
512 }
513 }
514
515 //-------------------------------------------------------------------------
516
517 private byte[] lookupResponse(Integer xid) throws NamingException {
518 //
519 // Check the queued responses: some other thread in between
520 // received the response for this request.
521 //
522 if (debug) {
523 dprint("LOOKUP for: " + xid +
524 "\tResponse Q:" + resps);
525 }
526 byte[] pkt;
527 if ((pkt = resps.get(xid)) != null) {
528 checkResponseCode(new Header(pkt, pkt.length));
529 synchronized (queuesLock) {
530 resps.remove(xid);
531 reqs.remove(xid);
532 }
533
534 if (debug) {
535 dprint("FOUND (" + Thread.currentThread() +
536 ") for:" + xid);
537 }
538 }
539 return pkt;
540 }
541
542 /*
543 * Checks the header of an incoming DNS response.
544 * Returns true if it matches the given xid and throws a naming
545 * exception, if appropriate, based on the response code.
546 */
547 private boolean isMatchResponse(byte[] pkt, int xid)
|