node-ikev2 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/configuration-attribute.d.ts +302 -0
- package/lib/src/configuration-attribute.js +851 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/index.js +2 -0
- package/lib/src/ip-address.d.ts +6 -0
- package/lib/src/ip-address.js +159 -0
- package/lib/src/payload.d.ts +4 -6
- package/lib/src/payload.js +17 -19
- package/lib/src/selector.d.ts +2 -2
- package/lib/src/selector.js +77 -17
- package/package.json +1 -1
|
@@ -0,0 +1,851 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CPAttributes = exports.P_CSCF_IP6_ADDRESS = exports.P_CSCF_IP4_ADDRESS = exports.INTERNAL_IP6_SUBNET = exports.SUPPORTED_ATTRIBUTES = exports.INTERNAL_IP4_SUBNET = exports.INTERNAL_IP6_DHCP = exports.INTERNAL_IP6_DNS = exports.INTERNAL_IP6_ADDRESS = exports.APPLICATION_VERSION = exports.INTERNAL_IP4_DHCP = exports.INTERNAL_IP4_NBNS = exports.INTERNAL_IP4_DNS = exports.INTERNAL_IP4_NETMASK = exports.INTERNAL_IP4_ADDRESS = exports.ConfigurationAttribute = exports.configurationAttributeType = void 0;
|
|
4
|
+
const ip_address_1 = require("./ip-address");
|
|
5
|
+
/**
|
|
6
|
+
* Configuration Attribute Types
|
|
7
|
+
*
|
|
8
|
+
* See: https://datatracker.ietf.org/doc/html/rfc7296#section-3.15.1
|
|
9
|
+
*
|
|
10
|
+
* Attribute Type Value Multi-Valued Length
|
|
11
|
+
* ------------------------------------------------------------
|
|
12
|
+
* INTERNAL_IP4_ADDRESS 1 YES* 0 or 4 octets
|
|
13
|
+
* INTERNAL_IP4_NETMASK 2 NO 0 or 4 octets
|
|
14
|
+
* INTERNAL_IP4_DNS 3 YES 0 or 4 octets
|
|
15
|
+
* INTERNAL_IP4_NBNS 4 YES 0 or 4 octets
|
|
16
|
+
* INTERNAL_IP4_DHCP 6 YES 0 or 4 octets
|
|
17
|
+
* APPLICATION_VERSION 7 NO 0 or more
|
|
18
|
+
* INTERNAL_IP6_ADDRESS 8 YES* 0 or 17 octets
|
|
19
|
+
* INTERNAL_IP6_DNS 10 YES 0 or 16 octets
|
|
20
|
+
* INTERNAL_IP6_DHCP 12 YES 0 or 16 octets
|
|
21
|
+
* INTERNAL_IP4_SUBNET 13 YES 0 or 8 octets
|
|
22
|
+
* SUPPORTED_ATTRIBUTES 14 NO Multiple of 2
|
|
23
|
+
* INTERNAL_IP6_SUBNET 15 YES 17 octets
|
|
24
|
+
*
|
|
25
|
+
* See: https://www.iana.org/assignments/ikev2-parameters/ikev2-parameters.xhtml#ikev2-parameters-20
|
|
26
|
+
*
|
|
27
|
+
* Value Attribute Type Multi-Valued Length Reference
|
|
28
|
+
* 0 Reserved [RFC7296]
|
|
29
|
+
* 1 INTERNAL_IP4_ADDRESS YES* 0 or 4 octets [RFC7296]
|
|
30
|
+
* 2 INTERNAL_IP4_NETMASK NO 0 or 4 octets [RFC7296]
|
|
31
|
+
* 3 INTERNAL_IP4_DNS YES 0 or 4 octets [RFC7296]
|
|
32
|
+
* 4 INTERNAL_IP4_NBNS YES 0 or 4 octets [RFC7296]
|
|
33
|
+
* 5 Reserved [RFC7296]
|
|
34
|
+
* 6 INTERNAL_IP4_DHCP YES 0 or 4 octets [RFC7296]
|
|
35
|
+
* 7 APPLICATION_VERSION NO 0 or more [RFC7296]
|
|
36
|
+
* 8 INTERNAL_IP6_ADDRESS YES* 0 or 17 octets [RFC7296]
|
|
37
|
+
* 9 Reserved [RFC7296]
|
|
38
|
+
* 10 INTERNAL_IP6_DNS YES 0 or 16 octets [RFC7296]
|
|
39
|
+
* 11 Reserved [RFC7296]
|
|
40
|
+
* 12 INTERNAL_IP6_DHCP YES 0 or 16 octets [RFC7296]
|
|
41
|
+
* 13 INTERNAL_IP4_SUBNET YES 0 or 8 octets [RFC7296]
|
|
42
|
+
* 14 SUPPORTED_ATTRIBUTES NO Multiple of 2 [RFC7296]
|
|
43
|
+
* 15 INTERNAL_IP6_SUBNET YES 17 octets [RFC7296]
|
|
44
|
+
* 16 MIP6_HOME_PREFIX YES 0 or 21 octets [RFC5026]
|
|
45
|
+
* 17 INTERNAL_IP6_LINK NO 8 or more [RFC5739]
|
|
46
|
+
* 18 INTERNAL_IP6_PREFIX YES 17 octets [RFC5739]
|
|
47
|
+
* 19 HOME_AGENT_ADDRESS NO 16 or 20 [http://www.3gpp.org/ftp/Specs/html-info/24302.htm][John_Meredith]
|
|
48
|
+
* 20 P_CSCF_IP4_ADDRESS YES 0 or 4 octets [RFC7651]
|
|
49
|
+
* 21 P_CSCF_IP6_ADDRESS YES 0 or 16 octets [RFC7651]
|
|
50
|
+
* 22 FTT_KAT NO 2 octets [TS 24.302 12.6.0]
|
|
51
|
+
* 23 EXTERNAL_SOURCE_IP4_NAT_INFO NO 0 or 6 [TS 29.139][Kimmo_Kymalainen]
|
|
52
|
+
* 24 TIMEOUT_PERIOD_FOR_LIVENESS_CHECK NO 0 or 4 octets [TS 24.302 13.4.0][Frederic_Firmin]
|
|
53
|
+
* 25 INTERNAL_DNS_DOMAIN YES 0 or more [RFC8598]
|
|
54
|
+
* 26 INTERNAL_DNSSEC_TA YES 0 or more [RFC8598]
|
|
55
|
+
* 27 ENCDNS_IP4 YES 0 or more [RFC9464]
|
|
56
|
+
* 28 ENCDNS_IP6 YES 0 or more [RFC9464]
|
|
57
|
+
* 29 ENCDNS_DIGEST_INFO YES 0 or more [RFC9464]
|
|
58
|
+
* 30-16383 Unassigned
|
|
59
|
+
* 16384-32767 Reserved for Private Use [RFC7296]
|
|
60
|
+
*/
|
|
61
|
+
var configurationAttributeType;
|
|
62
|
+
(function (configurationAttributeType) {
|
|
63
|
+
// Reserved 0
|
|
64
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_ADDRESS"] = 1] = "INTERNAL_IP4_ADDRESS";
|
|
65
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_NETMASK"] = 2] = "INTERNAL_IP4_NETMASK";
|
|
66
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_DNS"] = 3] = "INTERNAL_IP4_DNS";
|
|
67
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_NBNS"] = 4] = "INTERNAL_IP4_NBNS";
|
|
68
|
+
// Reserved 5
|
|
69
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_DHCP"] = 6] = "INTERNAL_IP4_DHCP";
|
|
70
|
+
configurationAttributeType[configurationAttributeType["APPLICATION_VERSION"] = 7] = "APPLICATION_VERSION";
|
|
71
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_ADDRESS"] = 8] = "INTERNAL_IP6_ADDRESS";
|
|
72
|
+
// Reserved 9
|
|
73
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_DNS"] = 10] = "INTERNAL_IP6_DNS";
|
|
74
|
+
// Reserved 11
|
|
75
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_DHCP"] = 12] = "INTERNAL_IP6_DHCP";
|
|
76
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP4_SUBNET"] = 13] = "INTERNAL_IP4_SUBNET";
|
|
77
|
+
configurationAttributeType[configurationAttributeType["SUPPORTED_ATTRIBUTES"] = 14] = "SUPPORTED_ATTRIBUTES";
|
|
78
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_SUBNET"] = 15] = "INTERNAL_IP6_SUBNET";
|
|
79
|
+
configurationAttributeType[configurationAttributeType["MIP6_HOME_PREFIX"] = 16] = "MIP6_HOME_PREFIX";
|
|
80
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_LINK"] = 17] = "INTERNAL_IP6_LINK";
|
|
81
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_IP6_PREFIX"] = 18] = "INTERNAL_IP6_PREFIX";
|
|
82
|
+
configurationAttributeType[configurationAttributeType["HOME_AGENT_ADDRESS"] = 19] = "HOME_AGENT_ADDRESS";
|
|
83
|
+
configurationAttributeType[configurationAttributeType["P_CSCF_IP4_ADDRESS"] = 20] = "P_CSCF_IP4_ADDRESS";
|
|
84
|
+
configurationAttributeType[configurationAttributeType["P_CSCF_IP6_ADDRESS"] = 21] = "P_CSCF_IP6_ADDRESS";
|
|
85
|
+
configurationAttributeType[configurationAttributeType["FTT_KAT"] = 22] = "FTT_KAT";
|
|
86
|
+
configurationAttributeType[configurationAttributeType["EXTERNAL_SOURCE_IP4_NAT_INFO"] = 23] = "EXTERNAL_SOURCE_IP4_NAT_INFO";
|
|
87
|
+
configurationAttributeType[configurationAttributeType["TIMEOUT_PERIOD_FOR_LIVENESS_CHECK"] = 24] = "TIMEOUT_PERIOD_FOR_LIVENESS_CHECK";
|
|
88
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_DNS_DOMAIN"] = 25] = "INTERNAL_DNS_DOMAIN";
|
|
89
|
+
configurationAttributeType[configurationAttributeType["INTERNAL_DNSSEC_TA"] = 26] = "INTERNAL_DNSSEC_TA";
|
|
90
|
+
configurationAttributeType[configurationAttributeType["ENCDNS_IP4"] = 27] = "ENCDNS_IP4";
|
|
91
|
+
configurationAttributeType[configurationAttributeType["ENCDNS_IP6"] = 28] = "ENCDNS_IP6";
|
|
92
|
+
configurationAttributeType[configurationAttributeType["ENCDNS_DIGEST_INFO"] = 29] = "ENCDNS_DIGEST_INFO";
|
|
93
|
+
// 30-16383 Unassigned
|
|
94
|
+
// 16384-32767 Reserved for Private Use
|
|
95
|
+
})(configurationAttributeType || (exports.configurationAttributeType = configurationAttributeType = {}));
|
|
96
|
+
/**
|
|
97
|
+
* Configuration Attributes
|
|
98
|
+
*
|
|
99
|
+
* 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
|
|
100
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
101
|
+
* |R| Attribute Type | Length |
|
|
102
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
103
|
+
* | |
|
|
104
|
+
* ~ Value ~
|
|
105
|
+
* | |
|
|
106
|
+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
107
|
+
*
|
|
108
|
+
* Figure 23: Configuration Attribute Format
|
|
109
|
+
*
|
|
110
|
+
* See: https://datatracker.ietf.org/doc/html/rfc7296#section-3.15.1
|
|
111
|
+
*
|
|
112
|
+
* As used in the PayloadCP
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
class ConfigurationAttribute {
|
|
116
|
+
constructor(type,
|
|
117
|
+
// public length: number,
|
|
118
|
+
value) {
|
|
119
|
+
this.type = type;
|
|
120
|
+
this.value = value;
|
|
121
|
+
if (type < 0 || type > 0x7fff) {
|
|
122
|
+
throw new Error("Invalid attribute type");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parses a ConfigurationAttribute from a Buffer
|
|
127
|
+
* @param {Buffer} buffer
|
|
128
|
+
* @static
|
|
129
|
+
* @public
|
|
130
|
+
* @returns {ConfigurationAttribute}
|
|
131
|
+
*/
|
|
132
|
+
static parse(buffer) {
|
|
133
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
134
|
+
throw new Error("Input must be a Buffer");
|
|
135
|
+
}
|
|
136
|
+
if (buffer.length < 4) {
|
|
137
|
+
throw new Error("Buffer too short for attribute header (minimum 4 bytes)");
|
|
138
|
+
}
|
|
139
|
+
const attributeType = buffer.readUInt16BE(0) & 0x7fff;
|
|
140
|
+
const length = buffer.readUInt16BE(2);
|
|
141
|
+
if (buffer.length < 4 + length) {
|
|
142
|
+
throw new Error(`Buffer too short for TLV attribute value. Expected ${4 + length} bytes, got ${buffer.length}`);
|
|
143
|
+
}
|
|
144
|
+
const value = buffer.subarray(4, 4 + length);
|
|
145
|
+
return new ConfigurationAttribute(attributeType, value);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Serializes a Configuration Attribute from a JSON object
|
|
149
|
+
* @param {any} json
|
|
150
|
+
* @static
|
|
151
|
+
* @public
|
|
152
|
+
* @returns {Buffer}
|
|
153
|
+
*/
|
|
154
|
+
static serializeJSON(json) {
|
|
155
|
+
const attributeType = json.attributeType;
|
|
156
|
+
const value = json.value;
|
|
157
|
+
const configurationAttribute = new ConfigurationAttribute(attributeType, value);
|
|
158
|
+
return configurationAttribute.serialize();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Serializes a Configuration Attribute to a Buffer
|
|
162
|
+
* @public
|
|
163
|
+
* @returns {Buffer}
|
|
164
|
+
*/
|
|
165
|
+
serialize() {
|
|
166
|
+
const buffer = Buffer.alloc(4 + this.value.length);
|
|
167
|
+
buffer.writeUInt16BE(this.type, 0);
|
|
168
|
+
buffer.writeUInt16BE(this.value.length, 2);
|
|
169
|
+
this.value.copy(buffer, 4);
|
|
170
|
+
return buffer;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Parses Configuration Attributes from a Buffer
|
|
174
|
+
* @param {Buffer} buffer
|
|
175
|
+
* @static
|
|
176
|
+
* @public
|
|
177
|
+
* @returns {ConfigurationAttribute[]}
|
|
178
|
+
*/
|
|
179
|
+
static parseConfigurationAttributes(buffer) {
|
|
180
|
+
const attributes = [];
|
|
181
|
+
let offset = 0;
|
|
182
|
+
while (offset + 4 <= buffer.length) {
|
|
183
|
+
// const attributeType = buffer.readUInt16BE(offset) & 0x7fff;
|
|
184
|
+
const attributeLength = buffer.readUInt16BE(offset + 2);
|
|
185
|
+
const attributeBuffer = buffer.subarray(offset, offset + 4 + attributeLength);
|
|
186
|
+
const attribute = ConfigurationAttribute.parse(attributeBuffer);
|
|
187
|
+
attributes.push(attribute);
|
|
188
|
+
offset += 4 + attributeLength;
|
|
189
|
+
}
|
|
190
|
+
return attributes;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Converts Configuration Attribute to JSON
|
|
194
|
+
* @public
|
|
195
|
+
* @returns {Record<string, any>} JSON object
|
|
196
|
+
*/
|
|
197
|
+
toJSON() {
|
|
198
|
+
return {
|
|
199
|
+
attributeType: this.type,
|
|
200
|
+
value: this.value.toString("hex"),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns a string representation of the configuration attribute
|
|
205
|
+
* @public
|
|
206
|
+
* @returns {string}
|
|
207
|
+
*/
|
|
208
|
+
toString() {
|
|
209
|
+
const prettyJson = this.toJSON();
|
|
210
|
+
prettyJson.configurationAttributeType = `${configurationAttributeType[prettyJson.attributeType]} (${prettyJson.attributeType})`;
|
|
211
|
+
prettyJson.value = this.value.toString("hex");
|
|
212
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.ConfigurationAttribute = ConfigurationAttribute;
|
|
216
|
+
class INTERNAL_IP4_ADDRESS extends ConfigurationAttribute {
|
|
217
|
+
constructor(address) {
|
|
218
|
+
if (address.length !== 0 && address.length !== 4) {
|
|
219
|
+
throw new Error("Invalid value length for INTERNAL_IP4_ADDRESS");
|
|
220
|
+
}
|
|
221
|
+
super(configurationAttributeType.INTERNAL_IP4_ADDRESS, address);
|
|
222
|
+
this.address = address;
|
|
223
|
+
}
|
|
224
|
+
static parse(buffer) {
|
|
225
|
+
if (buffer.length !== 0 && buffer.length !== 4) {
|
|
226
|
+
throw new Error("Invalid value length for INTERNAL_IP4_ADDRESS");
|
|
227
|
+
}
|
|
228
|
+
if (buffer.length === 0) {
|
|
229
|
+
return new INTERNAL_IP4_ADDRESS(Buffer.alloc(0));
|
|
230
|
+
}
|
|
231
|
+
return new INTERNAL_IP4_ADDRESS(buffer.subarray(0, 4));
|
|
232
|
+
}
|
|
233
|
+
static serializeJSON(json) {
|
|
234
|
+
const address = (0, ip_address_1.parseIPv4AddressString)(json.address);
|
|
235
|
+
return new INTERNAL_IP4_ADDRESS(address).serialize();
|
|
236
|
+
}
|
|
237
|
+
toJSON() {
|
|
238
|
+
return {
|
|
239
|
+
address: (0, ip_address_1.formatIPv4AddressBuffer)(this.address),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
toString() {
|
|
243
|
+
const prettyJson = this.toJSON();
|
|
244
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
exports.INTERNAL_IP4_ADDRESS = INTERNAL_IP4_ADDRESS;
|
|
248
|
+
class INTERNAL_IP4_NETMASK extends ConfigurationAttribute {
|
|
249
|
+
constructor(netmask) {
|
|
250
|
+
if (netmask.length !== 0 && netmask.length !== 4) {
|
|
251
|
+
throw new Error("Invalid value length for INTERNAL_IP4_NETMASK");
|
|
252
|
+
}
|
|
253
|
+
super(configurationAttributeType.INTERNAL_IP4_NETMASK, netmask);
|
|
254
|
+
this.netmask = netmask;
|
|
255
|
+
}
|
|
256
|
+
static parse(buffer) {
|
|
257
|
+
if (buffer.length !== 0 && buffer.length !== 4) {
|
|
258
|
+
throw new Error("Invalid value length for INTERNAL_IP4_NETMASK");
|
|
259
|
+
}
|
|
260
|
+
if (buffer.length === 0) {
|
|
261
|
+
return new INTERNAL_IP4_NETMASK(Buffer.alloc(0));
|
|
262
|
+
}
|
|
263
|
+
return new INTERNAL_IP4_NETMASK(buffer.subarray(0, 4));
|
|
264
|
+
}
|
|
265
|
+
static serializeJSON(json) {
|
|
266
|
+
const netmask = (0, ip_address_1.parseIPv4AddressString)(json.netmask);
|
|
267
|
+
return new INTERNAL_IP4_NETMASK(netmask).serialize();
|
|
268
|
+
}
|
|
269
|
+
toJSON() {
|
|
270
|
+
return {
|
|
271
|
+
netmask: (0, ip_address_1.formatIPv4AddressBuffer)(this.netmask),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
toString() {
|
|
275
|
+
const prettyJson = this.toJSON();
|
|
276
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
exports.INTERNAL_IP4_NETMASK = INTERNAL_IP4_NETMASK;
|
|
280
|
+
class INTERNAL_IP4_DNS extends ConfigurationAttribute {
|
|
281
|
+
constructor(dns) {
|
|
282
|
+
if (dns.length !== 0 && dns.length !== 4) {
|
|
283
|
+
throw new Error("Invalid value length for INTERNAL_IP4_DNS");
|
|
284
|
+
}
|
|
285
|
+
super(configurationAttributeType.INTERNAL_IP4_DNS, dns);
|
|
286
|
+
this.dns = dns;
|
|
287
|
+
}
|
|
288
|
+
static parse(buffer) {
|
|
289
|
+
if (buffer.length !== 0 && buffer.length !== 4) {
|
|
290
|
+
throw new Error("Invalid value length for INTERNAL_IP4_DNS");
|
|
291
|
+
}
|
|
292
|
+
if (buffer.length === 0) {
|
|
293
|
+
return new INTERNAL_IP4_DNS(Buffer.alloc(0));
|
|
294
|
+
}
|
|
295
|
+
return new INTERNAL_IP4_DNS(buffer.subarray(0, 4));
|
|
296
|
+
}
|
|
297
|
+
static serializeJSON(json) {
|
|
298
|
+
const dns = (0, ip_address_1.parseIPv4AddressString)(json.dns);
|
|
299
|
+
return new INTERNAL_IP4_DNS(dns).serialize();
|
|
300
|
+
}
|
|
301
|
+
toJSON() {
|
|
302
|
+
return {
|
|
303
|
+
dns: (0, ip_address_1.formatIPv4AddressBuffer)(this.dns),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
toString() {
|
|
307
|
+
const prettyJson = this.toJSON();
|
|
308
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.INTERNAL_IP4_DNS = INTERNAL_IP4_DNS;
|
|
312
|
+
class INTERNAL_IP4_NBNS extends ConfigurationAttribute {
|
|
313
|
+
constructor(nbns) {
|
|
314
|
+
if (nbns.length !== 0 && nbns.length !== 4) {
|
|
315
|
+
throw new Error("Invalid value length for INTERNAL_IP4_NBNS");
|
|
316
|
+
}
|
|
317
|
+
super(configurationAttributeType.INTERNAL_IP4_NBNS, nbns);
|
|
318
|
+
this.nbns = nbns;
|
|
319
|
+
}
|
|
320
|
+
static parse(buffer) {
|
|
321
|
+
if (buffer.length !== 0 && buffer.length !== 4) {
|
|
322
|
+
throw new Error("Invalid value length for INTERNAL_IP4_NBNS");
|
|
323
|
+
}
|
|
324
|
+
if (buffer.length === 0) {
|
|
325
|
+
return new INTERNAL_IP4_NBNS(Buffer.alloc(0));
|
|
326
|
+
}
|
|
327
|
+
return new INTERNAL_IP4_NBNS(buffer.subarray(0, 4));
|
|
328
|
+
}
|
|
329
|
+
static serializeJSON(json) {
|
|
330
|
+
const nbns = (0, ip_address_1.parseIPv4AddressString)(json.nbns);
|
|
331
|
+
return new INTERNAL_IP4_NBNS(nbns).serialize();
|
|
332
|
+
}
|
|
333
|
+
toJSON() {
|
|
334
|
+
return {
|
|
335
|
+
nbns: (0, ip_address_1.formatIPv4AddressBuffer)(this.nbns),
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
toString() {
|
|
339
|
+
const prettyJson = this.toJSON();
|
|
340
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
exports.INTERNAL_IP4_NBNS = INTERNAL_IP4_NBNS;
|
|
344
|
+
class INTERNAL_IP4_DHCP extends ConfigurationAttribute {
|
|
345
|
+
constructor(dhcp) {
|
|
346
|
+
if (dhcp.length !== 0 && dhcp.length !== 4) {
|
|
347
|
+
throw new Error("Invalid value length for INTERNAL_IP4_DHCP");
|
|
348
|
+
}
|
|
349
|
+
super(configurationAttributeType.INTERNAL_IP4_DHCP, dhcp);
|
|
350
|
+
this.dhcp = dhcp;
|
|
351
|
+
}
|
|
352
|
+
static parse(buffer) {
|
|
353
|
+
if (buffer.length !== 0 && buffer.length !== 4) {
|
|
354
|
+
throw new Error("Invalid value length for INTERNAL_IP4_DHCP");
|
|
355
|
+
}
|
|
356
|
+
if (buffer.length === 0) {
|
|
357
|
+
return new INTERNAL_IP4_DHCP(Buffer.alloc(0));
|
|
358
|
+
}
|
|
359
|
+
return new INTERNAL_IP4_DHCP(buffer.subarray(0, 4));
|
|
360
|
+
}
|
|
361
|
+
static serializeJSON(json) {
|
|
362
|
+
const dhcp = (0, ip_address_1.parseIPv4AddressString)(json.dhcp);
|
|
363
|
+
return new INTERNAL_IP4_DHCP(dhcp).serialize();
|
|
364
|
+
}
|
|
365
|
+
toJSON() {
|
|
366
|
+
return {
|
|
367
|
+
dhcp: (0, ip_address_1.formatIPv4AddressBuffer)(this.dhcp),
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
toString() {
|
|
371
|
+
const prettyJson = this.toJSON();
|
|
372
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
exports.INTERNAL_IP4_DHCP = INTERNAL_IP4_DHCP;
|
|
376
|
+
class APPLICATION_VERSION extends ConfigurationAttribute {
|
|
377
|
+
constructor(versionString) {
|
|
378
|
+
super(configurationAttributeType.APPLICATION_VERSION, Buffer.from(versionString));
|
|
379
|
+
this.versionString = versionString;
|
|
380
|
+
}
|
|
381
|
+
static parse(buffer) {
|
|
382
|
+
return new APPLICATION_VERSION(buffer.toString("utf8"));
|
|
383
|
+
}
|
|
384
|
+
static serializeJSON(json) {
|
|
385
|
+
const versionString = json.versionString;
|
|
386
|
+
const applicationVersion = new APPLICATION_VERSION(versionString);
|
|
387
|
+
return applicationVersion.serialize();
|
|
388
|
+
}
|
|
389
|
+
toJSON() {
|
|
390
|
+
return {
|
|
391
|
+
versionString: this.versionString,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
toString() {
|
|
395
|
+
const prettyJson = this.toJSON();
|
|
396
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
exports.APPLICATION_VERSION = APPLICATION_VERSION;
|
|
400
|
+
class INTERNAL_IP6_ADDRESS extends ConfigurationAttribute {
|
|
401
|
+
constructor(address, prefixLength) {
|
|
402
|
+
if (address.length !== 16 && address.length !== 0) {
|
|
403
|
+
throw new Error("Invalid value length for INTERNAL_IP6_ADDRESS");
|
|
404
|
+
}
|
|
405
|
+
var value;
|
|
406
|
+
if (address.length === 0) {
|
|
407
|
+
value = address;
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
if (prefixLength < 0 || prefixLength > 128) {
|
|
411
|
+
throw new Error("Invalid prefix length for INTERNAL_IP6_ADDRESS");
|
|
412
|
+
}
|
|
413
|
+
value = Buffer.alloc(17);
|
|
414
|
+
address.copy(value, 0);
|
|
415
|
+
value.writeUInt8(prefixLength, 16);
|
|
416
|
+
}
|
|
417
|
+
super(configurationAttributeType.INTERNAL_IP6_ADDRESS, value);
|
|
418
|
+
this.address = address;
|
|
419
|
+
this.prefixLength = prefixLength;
|
|
420
|
+
}
|
|
421
|
+
static parse(buffer) {
|
|
422
|
+
if (buffer.length !== 17 && buffer.length !== 0) {
|
|
423
|
+
throw new Error("Invalid value length for INTERNAL_IP6_ADDRESS");
|
|
424
|
+
}
|
|
425
|
+
if (buffer.length === 0) {
|
|
426
|
+
return new INTERNAL_IP6_ADDRESS(Buffer.alloc(0), 0);
|
|
427
|
+
}
|
|
428
|
+
return new INTERNAL_IP6_ADDRESS(buffer.subarray(0, 16), buffer.readUInt8(16));
|
|
429
|
+
}
|
|
430
|
+
static serializeJSON(json) {
|
|
431
|
+
const address = (0, ip_address_1.parseIPv6AddressString)(json.address);
|
|
432
|
+
const prefixLength = json.prefixLength;
|
|
433
|
+
return new INTERNAL_IP6_ADDRESS(address, prefixLength).serialize();
|
|
434
|
+
}
|
|
435
|
+
toJSON() {
|
|
436
|
+
return {
|
|
437
|
+
address: (0, ip_address_1.formatIPv6AddressBuffer)(this.address),
|
|
438
|
+
prefixLength: this.prefixLength,
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
toString() {
|
|
442
|
+
const prettyJson = this.toJSON();
|
|
443
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
exports.INTERNAL_IP6_ADDRESS = INTERNAL_IP6_ADDRESS;
|
|
447
|
+
class INTERNAL_IP6_DNS extends ConfigurationAttribute {
|
|
448
|
+
constructor(dns) {
|
|
449
|
+
if (dns.length !== 16 && dns.length !== 0) {
|
|
450
|
+
throw new Error("Invalid value length for INTERNAL_IP6_DNS");
|
|
451
|
+
}
|
|
452
|
+
super(configurationAttributeType.INTERNAL_IP6_DNS, dns);
|
|
453
|
+
this.dns = dns;
|
|
454
|
+
}
|
|
455
|
+
static parse(buffer) {
|
|
456
|
+
if (buffer.length !== 16 && buffer.length !== 0) {
|
|
457
|
+
throw new Error("Invalid value length for INTERNAL_IP6_DNS");
|
|
458
|
+
}
|
|
459
|
+
if (buffer.length === 0) {
|
|
460
|
+
return new INTERNAL_IP6_DNS(Buffer.alloc(0));
|
|
461
|
+
}
|
|
462
|
+
return new INTERNAL_IP6_DNS(buffer.subarray(0, 16));
|
|
463
|
+
}
|
|
464
|
+
static serializeJSON(json) {
|
|
465
|
+
const dns = (0, ip_address_1.parseIPv6AddressString)(json.dns);
|
|
466
|
+
return new INTERNAL_IP6_DNS(dns).serialize();
|
|
467
|
+
}
|
|
468
|
+
toJSON() {
|
|
469
|
+
return {
|
|
470
|
+
dns: (0, ip_address_1.formatIPv6AddressBuffer)(this.dns),
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
toString() {
|
|
474
|
+
const prettyJson = this.toJSON();
|
|
475
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
exports.INTERNAL_IP6_DNS = INTERNAL_IP6_DNS;
|
|
479
|
+
class INTERNAL_IP6_DHCP extends ConfigurationAttribute {
|
|
480
|
+
constructor(dhcp) {
|
|
481
|
+
if (dhcp.length !== 16 && dhcp.length !== 0) {
|
|
482
|
+
throw new Error("Invalid value length for INTERNAL_IP6_DHCP");
|
|
483
|
+
}
|
|
484
|
+
super(configurationAttributeType.INTERNAL_IP6_DHCP, dhcp);
|
|
485
|
+
this.dhcp = dhcp;
|
|
486
|
+
}
|
|
487
|
+
static parse(buffer) {
|
|
488
|
+
if (buffer.length !== 16 && buffer.length !== 0) {
|
|
489
|
+
throw new Error("Invalid value length for INTERNAL_IP6_DHCP");
|
|
490
|
+
}
|
|
491
|
+
if (buffer.length === 0) {
|
|
492
|
+
return new INTERNAL_IP6_DHCP(Buffer.alloc(0));
|
|
493
|
+
}
|
|
494
|
+
return new INTERNAL_IP6_DHCP(buffer.subarray(0, 16));
|
|
495
|
+
}
|
|
496
|
+
static serializeJSON(json) {
|
|
497
|
+
const dhcp = (0, ip_address_1.parseIPv6AddressString)(json.dhcp);
|
|
498
|
+
return new INTERNAL_IP6_DHCP(dhcp).serialize();
|
|
499
|
+
}
|
|
500
|
+
toJSON() {
|
|
501
|
+
return {
|
|
502
|
+
dhcp: (0, ip_address_1.formatIPv6AddressBuffer)(this.dhcp),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
toString() {
|
|
506
|
+
const prettyJson = this.toJSON();
|
|
507
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
exports.INTERNAL_IP6_DHCP = INTERNAL_IP6_DHCP;
|
|
511
|
+
class INTERNAL_IP4_SUBNET extends ConfigurationAttribute {
|
|
512
|
+
constructor(address, netmask) {
|
|
513
|
+
if (!((address.length == 4 && netmask.length == 4) ||
|
|
514
|
+
(address.length == 0 && netmask.length == 0))) {
|
|
515
|
+
throw new Error("Invalid value length for INTERNAL_IP4_SUBNET");
|
|
516
|
+
}
|
|
517
|
+
let value = Buffer.alloc(address.length + netmask.length);
|
|
518
|
+
address.copy(value, 0);
|
|
519
|
+
netmask.copy(value, address.length);
|
|
520
|
+
super(configurationAttributeType.INTERNAL_IP4_SUBNET, value);
|
|
521
|
+
this.address = address;
|
|
522
|
+
this.netmask = netmask;
|
|
523
|
+
}
|
|
524
|
+
static parse(buffer) {
|
|
525
|
+
if (buffer.length !== 8 && buffer.length != 0) {
|
|
526
|
+
throw new Error("Invalid value length for INTERNAL_IP4_SUBNET");
|
|
527
|
+
}
|
|
528
|
+
if (buffer.length === 0) {
|
|
529
|
+
return new INTERNAL_IP4_SUBNET(Buffer.alloc(0), Buffer.alloc(0));
|
|
530
|
+
}
|
|
531
|
+
return new INTERNAL_IP4_SUBNET(buffer.subarray(0, 4), buffer.subarray(4, 8));
|
|
532
|
+
}
|
|
533
|
+
static serializeJSON(json) {
|
|
534
|
+
const address = (0, ip_address_1.parseIPv4AddressString)(json.address);
|
|
535
|
+
const netmask = (0, ip_address_1.parseIPv4AddressString)(json.netmask);
|
|
536
|
+
return new INTERNAL_IP4_SUBNET(address, netmask).serialize();
|
|
537
|
+
}
|
|
538
|
+
toJSON() {
|
|
539
|
+
return {
|
|
540
|
+
address: (0, ip_address_1.formatIPv4AddressBuffer)(this.address),
|
|
541
|
+
netmask: (0, ip_address_1.formatIPv4AddressBuffer)(this.netmask),
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
toString() {
|
|
545
|
+
const prettyJson = this.toJSON();
|
|
546
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
exports.INTERNAL_IP4_SUBNET = INTERNAL_IP4_SUBNET;
|
|
550
|
+
class SUPPORTED_ATTRIBUTES extends ConfigurationAttribute {
|
|
551
|
+
constructor(values) {
|
|
552
|
+
let value = Buffer.alloc(values.length * 2);
|
|
553
|
+
values.forEach((cfgAttrType, index) => {
|
|
554
|
+
value.writeUInt16BE(cfgAttrType, index * 2);
|
|
555
|
+
});
|
|
556
|
+
super(configurationAttributeType.SUPPORTED_ATTRIBUTES, value);
|
|
557
|
+
this.values = values;
|
|
558
|
+
}
|
|
559
|
+
static parse(buffer) {
|
|
560
|
+
if (buffer.length % 2 !== 0) {
|
|
561
|
+
throw new Error("Invalid value length for SUPPORTED_ATTRIBUTES");
|
|
562
|
+
}
|
|
563
|
+
const values = [];
|
|
564
|
+
for (let i = 0; i < buffer.length; i += 2) {
|
|
565
|
+
values.push(buffer.readUInt16BE(i));
|
|
566
|
+
}
|
|
567
|
+
return new SUPPORTED_ATTRIBUTES(values);
|
|
568
|
+
}
|
|
569
|
+
static serializeJSON(json) {
|
|
570
|
+
return new SUPPORTED_ATTRIBUTES(json.values).serialize();
|
|
571
|
+
}
|
|
572
|
+
toJSON() {
|
|
573
|
+
return {
|
|
574
|
+
values: this.values,
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
toString() {
|
|
578
|
+
const prettyJson = this.toJSON();
|
|
579
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
exports.SUPPORTED_ATTRIBUTES = SUPPORTED_ATTRIBUTES;
|
|
583
|
+
class INTERNAL_IP6_SUBNET extends ConfigurationAttribute {
|
|
584
|
+
constructor(address, prefixLength) {
|
|
585
|
+
if (address.length !== 16 && address.length !== 0) {
|
|
586
|
+
throw new Error("Invalid value length for INTERNAL_IP6_SUBNET");
|
|
587
|
+
}
|
|
588
|
+
var value;
|
|
589
|
+
if (address.length === 0) {
|
|
590
|
+
value = address;
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
if (prefixLength < 0 || prefixLength > 128) {
|
|
594
|
+
throw new Error("Invalid prefix length for INTERNAL_IP6_SUBNET");
|
|
595
|
+
}
|
|
596
|
+
value = Buffer.alloc(17);
|
|
597
|
+
address.copy(value, 0);
|
|
598
|
+
value.writeUInt8(prefixLength, 16);
|
|
599
|
+
}
|
|
600
|
+
super(configurationAttributeType.INTERNAL_IP6_SUBNET, value);
|
|
601
|
+
this.address = address;
|
|
602
|
+
this.prefixLength = prefixLength;
|
|
603
|
+
}
|
|
604
|
+
static parse(buffer) {
|
|
605
|
+
if (buffer.length !== 17) {
|
|
606
|
+
throw new Error("Invalid value length for INTERNAL_IP6_SUBNET");
|
|
607
|
+
}
|
|
608
|
+
return new INTERNAL_IP6_SUBNET(buffer.subarray(0, 16), buffer.readUInt8(16));
|
|
609
|
+
}
|
|
610
|
+
static serializeJSON(json) {
|
|
611
|
+
const address = (0, ip_address_1.parseIPv6AddressString)(json.address);
|
|
612
|
+
const prefixLength = json.prefixLength;
|
|
613
|
+
return new INTERNAL_IP6_SUBNET(address, prefixLength).serialize();
|
|
614
|
+
}
|
|
615
|
+
toJSON() {
|
|
616
|
+
return {
|
|
617
|
+
address: (0, ip_address_1.formatIPv6AddressBuffer)(this.address),
|
|
618
|
+
prefixLength: this.prefixLength,
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
toString() {
|
|
622
|
+
const prettyJson = this.toJSON();
|
|
623
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
exports.INTERNAL_IP6_SUBNET = INTERNAL_IP6_SUBNET;
|
|
627
|
+
class P_CSCF_IP4_ADDRESS extends ConfigurationAttribute {
|
|
628
|
+
constructor(address) {
|
|
629
|
+
if (address.length !== 4 && address.length !== 0) {
|
|
630
|
+
throw new Error("Invalid value length for P_CSCF_IP4_ADDRESS");
|
|
631
|
+
}
|
|
632
|
+
super(configurationAttributeType.P_CSCF_IP4_ADDRESS, address);
|
|
633
|
+
this.address = address;
|
|
634
|
+
}
|
|
635
|
+
static parse(buffer) {
|
|
636
|
+
if (buffer.length !== 4 && buffer.length !== 0) {
|
|
637
|
+
throw new Error("Invalid value length for P_CSCF_IP4_ADDRESS");
|
|
638
|
+
}
|
|
639
|
+
if (buffer.length === 0) {
|
|
640
|
+
return new P_CSCF_IP4_ADDRESS(Buffer.alloc(0));
|
|
641
|
+
}
|
|
642
|
+
return new P_CSCF_IP4_ADDRESS(buffer.subarray(0, 4));
|
|
643
|
+
}
|
|
644
|
+
static serializeJSON(json) {
|
|
645
|
+
const address = (0, ip_address_1.parseIPv4AddressString)(json.address);
|
|
646
|
+
return new P_CSCF_IP4_ADDRESS(address).serialize();
|
|
647
|
+
}
|
|
648
|
+
toJSON() {
|
|
649
|
+
return {
|
|
650
|
+
address: (0, ip_address_1.formatIPv4AddressBuffer)(this.address),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
toString() {
|
|
654
|
+
const prettyJson = this.toJSON();
|
|
655
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
exports.P_CSCF_IP4_ADDRESS = P_CSCF_IP4_ADDRESS;
|
|
659
|
+
class P_CSCF_IP6_ADDRESS extends ConfigurationAttribute {
|
|
660
|
+
constructor(address) {
|
|
661
|
+
if (address.length !== 16 && address.length !== 0) {
|
|
662
|
+
throw new Error("Invalid value length for P_CSCF_IP6_ADDRESS");
|
|
663
|
+
}
|
|
664
|
+
super(configurationAttributeType.P_CSCF_IP6_ADDRESS, address);
|
|
665
|
+
this.address = address;
|
|
666
|
+
}
|
|
667
|
+
static parse(buffer) {
|
|
668
|
+
if (buffer.length !== 16 && buffer.length !== 0) {
|
|
669
|
+
throw new Error("Invalid value length for P_CSCF_IP6_ADDRESS");
|
|
670
|
+
}
|
|
671
|
+
if (buffer.length === 0) {
|
|
672
|
+
return new P_CSCF_IP6_ADDRESS(Buffer.alloc(0));
|
|
673
|
+
}
|
|
674
|
+
return new P_CSCF_IP6_ADDRESS(buffer.subarray(0, 16));
|
|
675
|
+
}
|
|
676
|
+
static serializeJSON(json) {
|
|
677
|
+
const address = (0, ip_address_1.parseIPv6AddressString)(json.address);
|
|
678
|
+
return new P_CSCF_IP6_ADDRESS(address).serialize();
|
|
679
|
+
}
|
|
680
|
+
toJSON() {
|
|
681
|
+
return {
|
|
682
|
+
address: (0, ip_address_1.formatIPv6AddressBuffer)(this.address),
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
toString() {
|
|
686
|
+
const prettyJson = this.toJSON();
|
|
687
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
exports.P_CSCF_IP6_ADDRESS = P_CSCF_IP6_ADDRESS;
|
|
691
|
+
class CPAttributes {
|
|
692
|
+
constructor() {
|
|
693
|
+
this.INTERNAL_IP4_ADDRESS = [];
|
|
694
|
+
this.INTERNAL_IP4_NETMASK = undefined;
|
|
695
|
+
this.INTERNAL_IP4_DNS = [];
|
|
696
|
+
this.INTERNAL_IP4_NBNS = [];
|
|
697
|
+
this.INTERNAL_IP4_DHCP = [];
|
|
698
|
+
this.APPLICATION_VERSION = undefined;
|
|
699
|
+
this.INTERNAL_IP6_ADDRESS = [];
|
|
700
|
+
this.INTERNAL_IP6_DNS = [];
|
|
701
|
+
this.INTERNAL_IP6_DHCP = [];
|
|
702
|
+
this.INTERNAL_IP4_SUBNET = [];
|
|
703
|
+
this.SUPPORTED_ATTRIBUTES = undefined;
|
|
704
|
+
this.INTERNAL_IP6_SUBNET = [];
|
|
705
|
+
this.P_CSCF_IP4_ADDRESS = [];
|
|
706
|
+
this.P_CSCF_IP6_ADDRESS = [];
|
|
707
|
+
this.OtherAttributes = [];
|
|
708
|
+
}
|
|
709
|
+
static parse(buffer) {
|
|
710
|
+
const cpAttributes = new CPAttributes();
|
|
711
|
+
let attributes = ConfigurationAttribute.parseConfigurationAttributes(buffer);
|
|
712
|
+
for (let attribute of attributes) {
|
|
713
|
+
switch (attribute.type) {
|
|
714
|
+
case configurationAttributeType.INTERNAL_IP4_ADDRESS:
|
|
715
|
+
cpAttributes.INTERNAL_IP4_ADDRESS.push(INTERNAL_IP4_ADDRESS.parse(attribute.value));
|
|
716
|
+
break;
|
|
717
|
+
case configurationAttributeType.INTERNAL_IP4_NETMASK:
|
|
718
|
+
cpAttributes.INTERNAL_IP4_NETMASK = INTERNAL_IP4_NETMASK.parse(attribute.value);
|
|
719
|
+
break;
|
|
720
|
+
case configurationAttributeType.INTERNAL_IP4_DNS:
|
|
721
|
+
cpAttributes.INTERNAL_IP4_DNS.push(INTERNAL_IP4_DNS.parse(attribute.value));
|
|
722
|
+
break;
|
|
723
|
+
case configurationAttributeType.INTERNAL_IP4_NBNS:
|
|
724
|
+
cpAttributes.INTERNAL_IP4_NBNS.push(INTERNAL_IP4_NBNS.parse(attribute.value));
|
|
725
|
+
break;
|
|
726
|
+
case configurationAttributeType.INTERNAL_IP4_DHCP:
|
|
727
|
+
cpAttributes.INTERNAL_IP4_DHCP.push(INTERNAL_IP4_DHCP.parse(attribute.value));
|
|
728
|
+
break;
|
|
729
|
+
case configurationAttributeType.APPLICATION_VERSION:
|
|
730
|
+
cpAttributes.APPLICATION_VERSION = APPLICATION_VERSION.parse(attribute.value);
|
|
731
|
+
break;
|
|
732
|
+
case configurationAttributeType.INTERNAL_IP6_ADDRESS:
|
|
733
|
+
cpAttributes.INTERNAL_IP6_ADDRESS.push(INTERNAL_IP6_ADDRESS.parse(attribute.value));
|
|
734
|
+
break;
|
|
735
|
+
case configurationAttributeType.INTERNAL_IP6_DNS:
|
|
736
|
+
cpAttributes.INTERNAL_IP6_DNS.push(INTERNAL_IP6_DNS.parse(attribute.value));
|
|
737
|
+
break;
|
|
738
|
+
case configurationAttributeType.INTERNAL_IP6_DHCP:
|
|
739
|
+
cpAttributes.INTERNAL_IP6_DHCP.push(INTERNAL_IP6_DHCP.parse(attribute.value));
|
|
740
|
+
break;
|
|
741
|
+
case configurationAttributeType.INTERNAL_IP4_SUBNET:
|
|
742
|
+
cpAttributes.INTERNAL_IP4_SUBNET.push(INTERNAL_IP4_SUBNET.parse(attribute.value));
|
|
743
|
+
break;
|
|
744
|
+
case configurationAttributeType.SUPPORTED_ATTRIBUTES:
|
|
745
|
+
cpAttributes.SUPPORTED_ATTRIBUTES = SUPPORTED_ATTRIBUTES.parse(attribute.value);
|
|
746
|
+
break;
|
|
747
|
+
case configurationAttributeType.INTERNAL_IP6_SUBNET:
|
|
748
|
+
cpAttributes.INTERNAL_IP6_SUBNET.push(INTERNAL_IP6_SUBNET.parse(attribute.value));
|
|
749
|
+
break;
|
|
750
|
+
case configurationAttributeType.P_CSCF_IP4_ADDRESS:
|
|
751
|
+
cpAttributes.P_CSCF_IP4_ADDRESS.push(P_CSCF_IP4_ADDRESS.parse(attribute.value));
|
|
752
|
+
break;
|
|
753
|
+
case configurationAttributeType.P_CSCF_IP6_ADDRESS:
|
|
754
|
+
cpAttributes.P_CSCF_IP6_ADDRESS.push(P_CSCF_IP6_ADDRESS.parse(attribute.value));
|
|
755
|
+
break;
|
|
756
|
+
default:
|
|
757
|
+
cpAttributes.OtherAttributes.push(attribute);
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return cpAttributes;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Serializes the configuration attributes to a buffer
|
|
765
|
+
* @public
|
|
766
|
+
* @returns {Buffer}
|
|
767
|
+
*/
|
|
768
|
+
serialize() {
|
|
769
|
+
let buffer = Buffer.alloc(0);
|
|
770
|
+
for (let attribute of this.INTERNAL_IP4_ADDRESS) {
|
|
771
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
772
|
+
}
|
|
773
|
+
if (this.INTERNAL_IP4_NETMASK) {
|
|
774
|
+
buffer = Buffer.concat([buffer, this.INTERNAL_IP4_NETMASK.serialize()]);
|
|
775
|
+
}
|
|
776
|
+
for (let attribute of this.INTERNAL_IP4_DNS) {
|
|
777
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
778
|
+
}
|
|
779
|
+
for (let attribute of this.INTERNAL_IP4_NBNS) {
|
|
780
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
781
|
+
}
|
|
782
|
+
for (let attribute of this.INTERNAL_IP4_DHCP) {
|
|
783
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
784
|
+
}
|
|
785
|
+
if (this.APPLICATION_VERSION) {
|
|
786
|
+
buffer = Buffer.concat([buffer, this.APPLICATION_VERSION.serialize()]);
|
|
787
|
+
}
|
|
788
|
+
for (let attribute of this.INTERNAL_IP6_ADDRESS) {
|
|
789
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
790
|
+
}
|
|
791
|
+
for (let attribute of this.INTERNAL_IP6_DNS) {
|
|
792
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
793
|
+
}
|
|
794
|
+
for (let attribute of this.INTERNAL_IP6_DHCP) {
|
|
795
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
796
|
+
}
|
|
797
|
+
for (let attribute of this.INTERNAL_IP4_SUBNET) {
|
|
798
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
799
|
+
}
|
|
800
|
+
if (this.SUPPORTED_ATTRIBUTES) {
|
|
801
|
+
buffer = Buffer.concat([buffer, this.SUPPORTED_ATTRIBUTES.serialize()]);
|
|
802
|
+
}
|
|
803
|
+
for (let attribute of this.INTERNAL_IP6_SUBNET) {
|
|
804
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
805
|
+
}
|
|
806
|
+
for (let attribute of this.P_CSCF_IP4_ADDRESS) {
|
|
807
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
808
|
+
}
|
|
809
|
+
for (let attribute of this.P_CSCF_IP6_ADDRESS) {
|
|
810
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
811
|
+
}
|
|
812
|
+
for (let attribute of this.OtherAttributes) {
|
|
813
|
+
buffer = Buffer.concat([buffer, attribute.serialize()]);
|
|
814
|
+
}
|
|
815
|
+
return buffer;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* Converts Configuration Attribute to JSON
|
|
819
|
+
* @public
|
|
820
|
+
* @returns {Record<string, any>}
|
|
821
|
+
*/
|
|
822
|
+
toJSON() {
|
|
823
|
+
return {
|
|
824
|
+
INTERNAL_IP4_ADDRESS: this.INTERNAL_IP4_ADDRESS,
|
|
825
|
+
INTERNAL_IP4_NETMASK: this.INTERNAL_IP4_NETMASK,
|
|
826
|
+
INTERNAL_IP4_DNS: this.INTERNAL_IP4_DNS,
|
|
827
|
+
INTERNAL_IP4_NBNS: this.INTERNAL_IP4_NBNS,
|
|
828
|
+
INTERNAL_IP4_DHCP: this.INTERNAL_IP4_DHCP,
|
|
829
|
+
APPLICATION_VERSION: this.APPLICATION_VERSION,
|
|
830
|
+
INTERNAL_IP6_ADDRESS: this.INTERNAL_IP6_ADDRESS,
|
|
831
|
+
INTERNAL_IP6_DNS: this.INTERNAL_IP6_DNS,
|
|
832
|
+
INTERNAL_IP6_DHCP: this.INTERNAL_IP6_DHCP,
|
|
833
|
+
INTERNAL_IP4_SUBNET: this.INTERNAL_IP4_SUBNET,
|
|
834
|
+
SUPPORTED_ATTRIBUTES: this.SUPPORTED_ATTRIBUTES,
|
|
835
|
+
INTERNAL_IP6_SUBNET: this.INTERNAL_IP6_SUBNET,
|
|
836
|
+
P_CSCF_IP4_ADDRESS: this.P_CSCF_IP4_ADDRESS,
|
|
837
|
+
P_CSCF_IP6_ADDRESS: this.P_CSCF_IP6_ADDRESS,
|
|
838
|
+
OtherAttributes: this.OtherAttributes,
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Returns a string representation of the configuration attributes
|
|
843
|
+
* @public
|
|
844
|
+
* @returns {string}
|
|
845
|
+
*/
|
|
846
|
+
toString() {
|
|
847
|
+
const prettyJson = this.toJSON();
|
|
848
|
+
return JSON.stringify(prettyJson, null, 2);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
exports.CPAttributes = CPAttributes;
|