static { protocols.setMaximum(0xFF); protocols.setNumericAllowed(true); protocols.add(NONE, "NONE"); protocols.add(TLS, "TLS"); protocols.add(EMAIL, "EMAIL"); protocols.add(DNSSEC, "DNSSEC"); protocols.add(IPSEC, "IPSEC"); protocols.add(ANY, "ANY"); }
public TypeBitmap(Tokenizer st) throws IOException { this(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int typecode = Type.value(t.value); if (typecode < 0) { throw st.exception("Invalid type: " + t.value); } types.add(Mnemonic.toInteger(typecode)); } st.unget(); }
public TypeBitmap(DNSInput in) throws WireParseException { this(); int lastbase = -1; while (in.remaining() > 0) { if (in.remaining() < 2) throw new WireParseException("invalid bitmap descriptor"); int mapbase = in.readU8(); if (mapbase < lastbase) throw new WireParseException("invalid ordering"); int maplength = in.readU8(); if (maplength > in.remaining()) throw new WireParseException("invalid bitmap"); for (int i = 0; i < maplength; i++) { int current = in.readU8(); if (current == 0) continue; for (int j = 0; j < 8; j++) { if ((current & (1 << (7 - j))) == 0) continue; int typecode = mapbase * 256 + +i * 8 + j; types.add(Mnemonic.toInteger(typecode)); } } } }
/** * Converts a textual representation of KEY flags into its numeric code. Integers in the range * 0..65535 are also accepted. * * @param s The textual representation of the protocol * @return The protocol code, or -1 on error. */ public static int value(String s) { int value; try { value = Integer.parseInt(s); if (value >= 0 && value <= 0xFFFF) { return value; } return -1; } catch (NumberFormatException e) { } StringTokenizer st = new StringTokenizer(s, "|"); value = 0; while (st.hasMoreTokens()) { int val = flags.getValue(st.nextToken()); if (val < 0) { return -1; } value |= val; } return value; }
public boolean contains(int typecode) { return types.contains(Mnemonic.toInteger(typecode)); }
/** * Converts a textual representation of a KEY protocol into its numeric code. Integers in the * range 0..255 are also accepted. * * @param s The textual representation of the protocol * @return The protocol code, or -1 on error. */ public static int value(String s) { return protocols.getValue(s); }
/** Converts an KEY protocol value into its textual representation */ public static String string(int type) { return protocols.getText(type); }
static { flags.setMaximum(0xFFFF); flags.setNumericAllowed(false); flags.add(NOCONF, "NOCONF"); flags.add(NOAUTH, "NOAUTH"); flags.add(NOKEY, "NOKEY"); flags.add(FLAG2, "FLAG2"); flags.add(EXTEND, "EXTEND"); flags.add(FLAG4, "FLAG4"); flags.add(FLAG5, "FLAG5"); flags.add(USER, "USER"); flags.add(ZONE, "ZONE"); flags.add(HOST, "HOST"); flags.add(NTYP3, "NTYP3"); flags.add(FLAG8, "FLAG8"); flags.add(FLAG9, "FLAG9"); flags.add(FLAG10, "FLAG10"); flags.add(FLAG11, "FLAG11"); flags.add(SIG0, "SIG0"); flags.add(SIG1, "SIG1"); flags.add(SIG2, "SIG2"); flags.add(SIG3, "SIG3"); flags.add(SIG4, "SIG4"); flags.add(SIG5, "SIG5"); flags.add(SIG6, "SIG6"); flags.add(SIG7, "SIG7"); flags.add(SIG8, "SIG8"); flags.add(SIG9, "SIG9"); flags.add(SIG10, "SIG10"); flags.add(SIG11, "SIG11"); flags.add(SIG12, "SIG12"); flags.add(SIG13, "SIG13"); flags.add(SIG14, "SIG14"); flags.add(SIG15, "SIG15"); }