blob: d3bda09d8c40d9ea644532e6e13e6e3b692568c6 [file] [log] [blame]
Jian Li672ebda2017-02-06 20:21:04 +09001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.lisp.msg.protocols;
17
Jian Li4fc55e32017-02-07 06:25:50 +090018import io.netty.buffer.ByteBuf;
19import org.onosproject.lisp.msg.exceptions.LispWriterException;
20
Jian Li672ebda2017-02-06 20:21:04 +090021/**
22 * LISP signature interface.
23 *
24 * <p>
25 * LISP signature format is defined in draft-ietf-lisp-ddt-09.
26 * https://tools.ietf.org/html/draft-ietf-lisp-ddt-09#page-14
27 *
28 * <pre>
29 * {@literal
30 * 0 1 2 3
31 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
32 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 * /| Original Record TTL |
34 * / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 * / | Signature Expiration |
36 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 * s | Signature Inception |
38 * i +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * g | Key Tag | Sig Length |
40 * | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * \ | Sig-Algorithm | Reserved | Reserved |
42 * \ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 * \ ~ Signature ~
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 * }</pre>
46 */
47public interface LispSignature {
48
Jian Li4fc55e32017-02-07 06:25:50 +090049 /**
50 * Obtains record TTL value.
51 *
52 * @return record TTL value
53 */
54 int getRecordTtl();
55
56 /**
57 * Obtains signature expiration.
58 *
59 * @return signature expiration
60 */
61 int getSigExpiration();
62
63 /**
64 * Obtains signature inception.
65 *
66 * @return signature inception
67 */
68 int getSigInception();
69
70 /**
71 * Obtains key tag.
72 *
73 * @return key tag
74 */
75 short getKeyTag();
76
77 /**
78 * Obtains signature length.
79 *
80 * @return signature length.
81 */
82 short getSigLength();
83
84 /**
85 * Obtains signature algorithm.
86 *
87 * @return signature algorithm
88 */
89 byte getSigAlgorithm();
90
91 /**
92 * Obtains signature.
93 *
94 * @return signature
95 */
96 int getSignature();
97
98 /**
99 * Writes LISP object into communication channel.
100 *
101 * @param byteBuf byte buffer
102 * @throws LispWriterException on error
103 */
104 void writeTo(ByteBuf byteBuf) throws LispWriterException;
105
106 /**
107 * A builder for LISP signature.
108 */
109 interface SignatureBuilder {
110
111 /**
112 * Sets record TTL value.
113 *
114 * @param recordTtl record TTL
115 * @return SignatureBuilder object
116 */
117 SignatureBuilder withRecordTtl(int recordTtl);
118
119 /**
120 * Sets signature expiration.
121 *
122 * @param sigExpiration signature expiration
123 * @return SignatureBuilder object
124 */
125 SignatureBuilder withSigExpiration(int sigExpiration);
126
127 /**
128 * Sets signature inception.
129 *
130 * @param sigInception signature inception
131 * @return SignatureBuilder object
132 */
133 SignatureBuilder withSigInception(int sigInception);
134
135 /**
136 * Sets key tag.
137 *
138 * @param keyTag key tag
139 * @return SignatureBuilder object
140 */
141 SignatureBuilder withKeyTag(short keyTag);
142
143 /**
144 * Sets signature length.
145 *
146 * @param sigLength signature length
147 * @return SignatureBuilder object
148 */
149 SignatureBuilder withSigLength(short sigLength);
150
151 /**
152 * Sets signature algorithm.
153 *
154 * @param sigAlgorithm signature algorithm
155 * @return SignatureBuilder object
156 */
157 SignatureBuilder withSigAlgorithm(byte sigAlgorithm);
158
159 /**
160 * Sets signature.
161 *
162 * @param signature signature
163 * @return SignatureBuilder object
164 */
165 SignatureBuilder withSignature(int signature);
166
167 /**
168 * Builds LISP signature object.
169 *
170 * @return LISP signature object
171 */
172 LispSignature build();
173 }
Jian Li672ebda2017-02-06 20:21:04 +0900174}