-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathPXRecord.java
More file actions
84 lines (71 loc) · 2.18 KB
/
Copy pathPXRecord.java
File metadata and controls
84 lines (71 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2004 Brian Wellington (bwelling@xbill.org)
package org.xbill.DNS;
import java.io.IOException;
/**
* X.400 mail mapping record.
*
* @author Brian Wellington
* @see <a href="https://datatracker.ietf.org/doc/html/rfc2163">RFC 2163: Using the Internet DNS to
* Distribute MIXER Conformant Global Address Mapping (MCGAM)</a>
*/
public class PXRecord extends Record {
private int preference;
private Name map822;
private Name mapX400;
PXRecord() {}
/**
* Creates an PX Record from the given data
*
* @param preference The preference of this mail address.
* @param map822 The RFC 822 component of the mail address.
* @param mapX400 The X.400 component of the mail address.
*/
public PXRecord(Name name, int dclass, long ttl, int preference, Name map822, Name mapX400) {
super(name, Type.PX, dclass, ttl);
this.preference = checkU16("preference", preference);
this.map822 = checkName("map822", map822);
this.mapX400 = checkName("mapX400", mapX400);
}
@Override
protected void rrFromWire(DNSInput in) throws IOException {
preference = in.readU16();
map822 = new Name(in);
mapX400 = new Name(in);
}
@Override
protected void rdataFromString(Tokenizer st, Name origin) throws IOException {
preference = st.getUInt16();
map822 = st.getName(origin);
mapX400 = st.getName(origin);
}
/** Converts the PX Record to a String */
@Override
protected String rrToString() {
StringBuilder sb = new StringBuilder();
sb.append(preference);
sb.append(" ");
sb.append(map822);
sb.append(" ");
sb.append(mapX400);
return sb.toString();
}
@Override
protected void rrToWire(DNSOutput out, Compression c, boolean canonical) {
out.writeU16(preference);
map822.toWire(out, null, canonical);
mapX400.toWire(out, null, canonical);
}
/** Gets the preference of the route. */
public int getPreference() {
return preference;
}
/** Gets the RFC 822 component of the mail address. */
public Name getMap822() {
return map822;
}
/** Gets the X.400 component of the mail address. */
public Name getMapX400() {
return mapX400;
}
}