📄 wksrecord.java
字号:
public static final int SUPDUP = 95; /** Swift Remote Virtual File Protocol */ public static final int SWIFT_RVF = 97; /** TAC News */ public static final int TACNEWS = 98; /** Metagram Relay */ public static final int METAGRAM = 99; /** NIC Host Name Server */ public static final int HOSTNAME = 101; /** ISO-TSAP */ public static final int ISO_TSAP = 102; /** X400 */ public static final int X400 = 103; /** X400-SND */ public static final int X400_SND = 104; /** Mailbox Name Nameserver */ public static final int CSNET_NS = 105; /** Remote Telnet Service */ public static final int RTELNET = 107; /** Post Office Protocol - Version 2 */ public static final int POP_2 = 109; /** SUN Remote Procedure Call */ public static final int SUNRPC = 111; /** Authentication Service */ public static final int AUTH = 113; /** Simple File Transfer Protocol */ public static final int SFTP = 115; /** UUCP Path Service */ public static final int UUCP_PATH = 117; /** Network News Transfer Protocol */ public static final int NNTP = 119; /** HYDRA Expedited Remote Procedure */ public static final int ERPC = 121; /** Network Time Protocol */ public static final int NTP = 123; /** Locus PC-Interface Net Map Server */ public static final int LOCUS_MAP = 125; /** Locus PC-Interface Conn Server */ public static final int LOCUS_CON = 127; /** Password Generator Protocol */ public static final int PWDGEN = 129; /** CISCO FNATIVE */ public static final int CISCO_FNA = 130; /** CISCO TNATIVE */ public static final int CISCO_TNA = 131; /** CISCO SYSMAINT */ public static final int CISCO_SYS = 132; /** Statistics Service */ public static final int STATSRV = 133; /** INGRES-NET Service */ public static final int INGRES_NET = 134; /** Location Service */ public static final int LOC_SRV = 135; /** PROFILE Naming System */ public static final int PROFILE = 136; /** NETBIOS Name Service */ public static final int NETBIOS_NS = 137; /** NETBIOS Datagram Service */ public static final int NETBIOS_DGM = 138; /** NETBIOS Session Service */ public static final int NETBIOS_SSN = 139; /** EMFIS Data Service */ public static final int EMFIS_DATA = 140; /** EMFIS Control Service */ public static final int EMFIS_CNTL = 141; /** Britton-Lee IDM */ public static final int BL_IDM = 142; /** Survey Measurement */ public static final int SUR_MEAS = 243; /** LINK */ public static final int LINK = 245; private static Mnemonic services = new Mnemonic("TCP/UDP service", Mnemonic.CASE_LOWER); static { services.setMaximum(0xFFFF); services.setNumericAllowed(true); services.add(RJE, "rje"); services.add(ECHO, "echo"); services.add(DISCARD, "discard"); services.add(USERS, "users"); services.add(DAYTIME, "daytime"); services.add(QUOTE, "quote"); services.add(CHARGEN, "chargen"); services.add(FTP_DATA, "ftp-data"); services.add(FTP, "ftp"); services.add(TELNET, "telnet"); services.add(SMTP, "smtp"); services.add(NSW_FE, "nsw-fe"); services.add(MSG_ICP, "msg-icp"); services.add(MSG_AUTH, "msg-auth"); services.add(DSP, "dsp"); services.add(TIME, "time"); services.add(RLP, "rlp"); services.add(GRAPHICS, "graphics"); services.add(NAMESERVER, "nameserver"); services.add(NICNAME, "nicname"); services.add(MPM_FLAGS, "mpm-flags"); services.add(MPM, "mpm"); services.add(MPM_SND, "mpm-snd"); services.add(NI_FTP, "ni-ftp"); services.add(LOGIN, "login"); services.add(LA_MAINT, "la-maint"); services.add(DOMAIN, "domain"); services.add(ISI_GL, "isi-gl"); services.add(NI_MAIL, "ni-mail"); services.add(VIA_FTP, "via-ftp"); services.add(TACACS_DS, "tacacs-ds"); services.add(BOOTPS, "bootps"); services.add(BOOTPC, "bootpc"); services.add(TFTP, "tftp"); services.add(NETRJS_1, "netrjs-1"); services.add(NETRJS_2, "netrjs-2"); services.add(NETRJS_3, "netrjs-3"); services.add(NETRJS_4, "netrjs-4"); services.add(FINGER, "finger"); services.add(HOSTS2_NS, "hosts2-ns"); services.add(SU_MIT_TG, "su-mit-tg"); services.add(MIT_DOV, "mit-dov"); services.add(DCP, "dcp"); services.add(SUPDUP, "supdup"); services.add(SWIFT_RVF, "swift-rvf"); services.add(TACNEWS, "tacnews"); services.add(METAGRAM, "metagram"); services.add(HOSTNAME, "hostname"); services.add(ISO_TSAP, "iso-tsap"); services.add(X400, "x400"); services.add(X400_SND, "x400-snd"); services.add(CSNET_NS, "csnet-ns"); services.add(RTELNET, "rtelnet"); services.add(POP_2, "pop-2"); services.add(SUNRPC, "sunrpc"); services.add(AUTH, "auth"); services.add(SFTP, "sftp"); services.add(UUCP_PATH, "uucp-path"); services.add(NNTP, "nntp"); services.add(ERPC, "erpc"); services.add(NTP, "ntp"); services.add(LOCUS_MAP, "locus-map"); services.add(LOCUS_CON, "locus-con"); services.add(PWDGEN, "pwdgen"); services.add(CISCO_FNA, "cisco-fna"); services.add(CISCO_TNA, "cisco-tna"); services.add(CISCO_SYS, "cisco-sys"); services.add(STATSRV, "statsrv"); services.add(INGRES_NET, "ingres-net"); services.add(LOC_SRV, "loc-srv"); services.add(PROFILE, "profile"); services.add(NETBIOS_NS, "netbios-ns"); services.add(NETBIOS_DGM, "netbios-dgm"); services.add(NETBIOS_SSN, "netbios-ssn"); services.add(EMFIS_DATA, "emfis-data"); services.add(EMFIS_CNTL, "emfis-cntl"); services.add(BL_IDM, "bl-idm"); services.add(SUR_MEAS, "sur-meas"); services.add(LINK, "link"); } /** * Converts a TCP/UDP service port number into its textual * representation. */ public static String string(int type) { return services.getText(type); } /** * Converts a textual representation of a TCP/UDP service into its * port number. Integers in the range 0..65535 are also accepted. * @param s The textual representation of the service. * @return The port number, or -1 on error. */ public static int value(String s) { return services.getValue(s); }}private byte [] address;private int protocol;private int [] services;WKSRecord() {}RecordgetObject() { return new WKSRecord();}/** * Creates a WKS Record from the given data * @param address The IP address * @param protocol The IP protocol number * @param services An array of supported services, represented by port number. */publicWKSRecord(Name name, int dclass, long ttl, InetAddress address, int protocol, int [] services){ super(name, Type.WKS, dclass, ttl); if (Address.familyOf(address) != Address.IPv4) throw new IllegalArgumentException("invalid IPv4 address"); this.address = address.getAddress(); this.protocol = checkU8("protocol", protocol); for (int i = 0; i < services.length; i++) { checkU16("service", services[i]); } this.services = new int[services.length]; System.arraycopy(services, 0, this.services, 0, services.length); Arrays.sort(this.services);}voidrrFromWire(DNSInput in) throws IOException { address = in.readByteArray(4); protocol = in.readU8(); byte [] array = in.readByteArray(); List list = new ArrayList(); for (int i = 0; i < array.length; i++) { for (int j = 0; j < 8; j++) { int octet = array[i] & 0xFF; if ((octet & (1 << (7 - j))) != 0) { list.add(new Integer(i * 8 + j)); } } } services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); }}voidrdataFromString(Tokenizer st, Name origin) throws IOException { String s = st.getString(); address = Address.toByteArray(s, Address.IPv4); if (address == null) throw st.exception("invalid address"); s = st.getString(); protocol = Protocol.value(s); if (protocol < 0) { throw st.exception("Invalid IP protocol: " + s); } List list = new ArrayList(); while (true) { Tokenizer.Token t = st.get(); if (!t.isString()) break; int service = Service.value(t.value); if (service < 0) { throw st.exception("Invalid TCP/UDP service: " + t.value); } list.add(new Integer(service)); } st.unget(); services = new int[list.size()]; for (int i = 0; i < list.size(); i++) { services[i] = ((Integer) list.get(i)).intValue(); }}/** * Converts rdata to a String */StringrrToString() { StringBuffer sb = new StringBuffer(); sb.append(Address.toDottedQuad(address)); sb.append(" "); sb.append(protocol); for (int i = 0; i < services.length; i++) { sb.append(" " + services[i]); } return sb.toString();}/** * Returns the IP address. */public InetAddressgetAddress() { try { return InetAddress.getByAddress(address); } catch (UnknownHostException e) { return null; }}/** * Returns the IP protocol. */public intgetProtocol() { return protocol;}/** * Returns the services provided by the host on the specified address. */public int []getServices() { return services;}voidrrToWire(DNSOutput out, Compression c, boolean canonical) { out.writeByteArray(address); out.writeU8(protocol); int highestPort = services[services.length - 1]; byte [] array = new byte[highestPort / 8 + 1]; for (int i = 0; i < services.length; i++) { int port = services[i]; array[port / 8] |= (1 << (7 - port % 8)); } out.writeByteArray(array);}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -