-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathonvif-audit.js
More file actions
671 lines (582 loc) · 30.7 KB
/
onvif-audit.js
File metadata and controls
671 lines (582 loc) · 30.7 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
/**
* (C) Roger Hardiman <opensource@rjh.org.uk>
* First Release - May 2018
* Licenced with the MIT Licence
*
* Perform a brute force scan of the network looking for ONVIF devices
* For each device, save the make and model and a snapshot in the audit folder
*
* Can also use ONVIF Discovery to trigger the scan
*/
var IPADDRESS = '192.168.1.1-192.168.1.254', // single address or a range
PORT = '80',
USERNAME = 'onvifusername',
PASSWORD = 'onvifpassword';
var onvif = require('onvif');
var Cam = onvif.Cam;
var flow = require('nimble');
var args = require('commander');
var fs = require('fs');
var dateTime = require('node-datetime');
var path = require('path');
var xml2js = require('xml2js')
var stripPrefix = require('xml2js').processors.stripPrefix;
// Show Version
var version = require('./package.json').version;
args.version(version);
args.description('ONVIF Camera Audit');
args.option('-f, --filename <value>', 'Filename of JSON file with IP Address List');
args.option('-i, --ipaddress <value>', 'IP Address (x.x.x.x) or IP Address Range (x.x.x.x-y.y.y.y)');
args.option('-P, --port <value>', 'ONVIF Port. Default 80');
args.option('-u, --username <value>', 'ONVIF Username');
args.option('-p, --password <value>', 'ONVIF Password');
args.option('-s, --scan', 'Discover Network devices on local subnet');
args.parse(process.argv);
if (!args) {
args.help();
process.exit(1);
}
if (!args.filename && !args.ipaddress && !args.scan) {
console.log('Requires either a Filename (-f) or an IP Address/IP Range (-i) or a Scan (-s)');
console.log('Use -h for details');
process.exit(1);
}
let time_now = dateTime.create();
let folder = 'onvif_audit_report_' + time_now.format('Y_m_d_H_M_S');
try {
fs.mkdirSync(folder);
} catch (e) {
console.log('Unable to create log folder')
process.exit(1)
}
if (args.ipaddress) {
// Connection Details and IP Address supplied in the Command Line
IPADDRESS = args.ipaddress;
if (args.port) PORT = args.port;
if (args.username) USERNAME = args.username;
if (args.password) PASSWORD = args.password;
// Perform an Audit of all the cameras in the IP address Range
perform_audit(IPADDRESS, PORT, USERNAME, PASSWORD, folder);
}
if (args.filename) {
// Connection details supplied in a .JSON file
let contents = fs.readFileSync(args.filename);
let file = JSON.parse(contents);
if (file.cameralist && file.cameralist.length > 0) {
// process each item in the camera list
//Note - forEach is asynchronous - you don't know when it has completed
file.cameralist.forEach(function (item) {
// check IP range start and end
if (item.ipaddress) IPADDRESS = item.ipaddress;
if (item.port) PORT = item.port;
if (item.username) USERNAME = item.username;
if (item.password) PASSWORD = item.password;
perform_audit(IPADDRESS, PORT, USERNAME, PASSWORD, folder);
}
);
}
}
if (args.scan) {
console.log("Probing for 5 seconds");
let scanResults = [];
// set up an event handler which is called for each device discovered
onvif.Discovery.on('device', function (cam, rinfo, xml) {
// function will be called as soon as the NVT responses
/* Filter out xml name spaces */
xml = xml.replace(/xmlns([^=]*?)=(".*?")/g, '');
let parser = new xml2js.Parser({
attrkey: 'attr',
charkey: 'payload', // this ensures the payload is called .payload regardless of whether the XML Tags have Attributes or not
explicitCharkey: true,
tagNameProcessors: [stripPrefix] // strip namespace eg tt:Data -> Data
});
parser.parseString(xml,
function (err, result) {
if (err) return;
// By default xml2js will return different json structures depending on whether there are 'attributes' in the XML
// For example <MyTag value="123">HELLO</MyTag> will return value=123 as the '$ field and HELLO as the '_' field
// For example <MyTag>HELLO</MyTag> does not use the '$' or '_' fields.
// To make things easier to handle, we use parser options to place the data we want in a 'payload' field
let urn = result['Envelope']['Body'][0]['ProbeMatches'][0]['ProbeMatch'][0]['EndpointReference'][0]['Address'][0].payload.trim();
let xaddrs = result['Envelope']['Body'][0]['ProbeMatches'][0]['ProbeMatch'][0]['XAddrs'][0].payload.trim(); // Axis add whitespace on end. Remove it.
let scopes = result['Envelope']['Body'][0]['ProbeMatches'][0]['ProbeMatch'][0]['Scopes'][0].payload.trim(); // Axis add whitespace on end. Remove it.
scopes = scopes.split(" ");
let hardware = "";
let name = "";
for (let i = 0; i < scopes.length; i++) {
// use decodeUri to conver %20 to ' '
if (scopes[i].includes('onvif://www.onvif.org/name')) name = decodeURI(scopes[i].substring(27));
if (scopes[i].includes('onvif://www.onvif.org/hardware')) hardware = decodeURI(scopes[i].substring(31));
}
process.stdout.write(".");
const newItem = {
rinfo,
name,
hardware,
xaddrs,
urn,
scopes
};
scanResults.push(newItem);
}
);
})
onvif.Discovery.on('error', function (err) {
// ignore discovery errors
})
// start the probe
// resolve=false means Do not create Cam objects
onvif.Discovery.probe({ resolve: false }, function() {
// completion callback
process.stdout.write("\n");
// sort the Scan Results by IP Address
scanResults.sort((a,b) => {
// Check we are matching IPv4 against IPv6. If so sort IPv4 first
if (a.rinfo.family < b.rinfo.family)
return -1;
else if (a.rinfo.family > b.rinfo.family)
return 1;
else {
// A and B are both the same "family" (IPv4 or IPv6)
if (a.rinfo.family == 'IPv4') {
// IPv4 - sort numerically
return toLong(a.rinfo.address) - toLong(b.rinfo.address);
}
else if (a.rinfo.family == 'IPv6') {
// IPv6 - sort by String. Could be improved
if (a.rinfo.address < b.rinfo.address) return -1;
else if (a.rinfo.address > b.rinfo.address) return 1;
else return 0;
}
else {
// Unknown IP family
return 0;
}
}
});
for(const item of scanResults) {
let msg = item.rinfo.address + ' (' + item.name + ') (' + item.hardware + ') (' + item.xaddrs + ') (' + item.urn + ')';
console.log(msg);
}
console.log("Total " + scanResults.length);
});
}
// program ends here (just functions below)
function perform_audit(ip_addresses, port, username, password, folder) {
let ip_list = [];
// Valid IP addresses are
// a) Single address 1.2.3.4
// b) Range 10.10.10.50-10.10.10.99
// c) List 1.1.1.1,2.2.2.2,3.3.3.3
// d) Mixture 1.2.3.4,10.10.10.50-10.10.10.99
ip_addresses = ip_addresses.split(',');
for (let i = 0; i < ip_addresses.length; i++) {
let item = ip_addresses[i];
if (item.includes('-')) {
// item contains '-'. Split on the '-'
let split_str = item.split('-');
if (split_str.length != 2) {
console.log('IP address format incorrect. Should by x.x.x.x-y.y.y.y');
process.exit(1);
}
let ip_start = split_str[0];
let ip_end = split_str[1];
let tmp_list = generate_range(ip_start, ip_end);
// Copy
for (let x = 0; x < tmp_list.length; x++) ip_list.push(tmp_list[x]);
}
else {
// item does not include a '-' symbol
ip_list.push(item);
}
}
// console.log('Scanning ' + ip_list.length + ' addresses from ' + ip_list[0] + ' to ' + ip_list[ip_list.length-1]);
// hide error messages
console.error = function () { };
// try each IP address and each Port
ip_list.forEach(function (ip_entry) {
// workaround the ONVIF Library API
// Cam() with a username and password tries to connect (and genertes a callback error)
// and then it tries to call some SOAP methods which fails (and it generates a callback error)
let shown_error = false;
console.log("Connecting to " + ip_entry + ':' + port);
const c = new Cam({
hostname: ip_entry,
username: username,
password: password,
port: port,
timeout: 5000
}, function CamFunc(err) {
if (err) {
if (shown_error == false) {
console.log('------------------------------');
console.log("Cannot connect to " + ip_entry + ":" + port);
// cut the error at \n
if (err.message) console.log(err.message);
else console.log(err);
console.log('------------------------------');
shown_error = true;
}
return;
}
let cam_obj = this;
let got_date;
let got_info;
let got_videosources = [];
let got_profiles = [];
let bestProfile = []; // The preferred Profile indexed by Video Source.
let got_snapshots = []; // JPEG Imag URLs, indexed by Video Source
let got_livestreams = []; // RTSP URLs, indexed by Video Source
// Use Nimble to execute each ONVIF function in turn
// This is used so we can wait on all ONVIF replies before
// writing to the console
flow.series([
function (nimble_callback) {
cam_obj.getSystemDateAndTime(function (err, date) {
if (!err) got_date = date;
nimble_callback();
});
},
function (nimble_callback) {
cam_obj.getDeviceInformation(function (err, info) {
if (!err) got_info = info;
nimble_callback();
});
},
function (nimble_callback) {
try {
cam_obj.getVideoSources(function (err, videoSources) {
if (!err) {
got_videosources = videoSources;
for (let i = 0; i < got_videosources.length; i++) {
// create empty placeholders
bestProfile.push({});
got_snapshots.push({videoSourceToken: null, uri: null});
got_livestreams.push({tcp: null, udp: null, http: null, multicast: null});
}
}
nimble_callback();
});
} catch {
nimble_callback();
}
},
function (nimble_callback) {
try {
cam_obj.getProfiles(function (err, profiles) {
if (!err) got_profiles = profiles;
nimble_callback();
});
} catch {
nimble_callback();
}
},
function (nimble_callback) {
// Compare VideoSources with Profiles.
// Get the 'best' ONVIF Profile Token for each Video Source
for (let src_idx = 0; src_idx < got_videosources.length; src_idx++) {
const videoSource = got_videosources[src_idx];
// Get the 'best' profile for this videoSource token
// For most cameras we just find the first Profile which has the Video Source Token
// but Hanwha emit the JPEG Profile first, then H264, then H265. So we have to find the 'best' Profile ourselves.
// The Best one is the first H265, otherwise the first H264, otherwise the first MPEG4 otherwise the first JPEG stream
let firstH265 = got_profiles.findIndex(item =>
item.videoSourceConfiguration && item.videoEncoderConfiguration
&& item.videoSourceConfiguration.sourceToken == videoSource.$.token
&& item.videoEncoderConfiguration.encoding == "H265");
let firstH264 = got_profiles.findIndex(item =>
item.videoSourceConfiguration && item.videoEncoderConfiguration
&& item.videoSourceConfiguration.sourceToken == videoSource.$.token
&& item.videoEncoderConfiguration.encoding == "H264");
let firstMPEG4 = got_profiles.findIndex(item =>
item.videoSourceConfiguration && item.videoEncoderConfiguration
&& item.videoSourceConfiguration.sourceToken == videoSource.$.token
&& item.videoEncoderConfiguration.encoding == "MPEG4");
let firstJPEG = got_profiles.findIndex(item =>
item.videoSourceConfiguration && item.videoEncoderConfiguration
&& item.videoSourceConfiguration.sourceToken == videoSource.$.token
&& item.videoEncoderConfiguration.encoding == "JPEG");
let firstOther = got_profiles.findIndex(item =>
item.videoSourceConfiguration && item.videoEncoderConfiguration
&& item.videoSourceConfiguration.sourceToken == videoSource.$.token
);
if (firstH265 >= 0) bestProfile[src_idx] = got_profiles[firstH265];
else if (firstH264 >= 0) bestProfile[src_idx] = got_profiles[firstH264];
else if (firstMPEG4 >= 0) bestProfile[src_idx] = got_profiles[firstMPEG4];
else if (firstJPEG >= 0) bestProfile[src_idx] = got_profiles[firstJPEG];
else bestProfile[src_idx] = got_profiles[firstOther];
}
nimble_callback();
},
function (nimble_callback) {
try {
// The ONVIF device may have multiple Video Sources
// eg 4 channel IP encoder or Panoramic Cameras
// Grab a JPEG Image from each VideoSource
// Note. The Nimble Callback is only called once all ONVIF replies have been returned
const reply_max = got_videosources.length;
let reply_count = 0;
for (let src_idx = 0; src_idx < got_videosources.length; src_idx++) {
const videoSource = got_videosources[src_idx];
cam_obj.getSnapshotUri({ profileToken: bestProfile[src_idx].$.token}, (err, getUri_result) => {
reply_count++;
if (!err && getUri_result) {
got_snapshots[src_idx] = {videoSourceToken: videoSource.$.token, uri: getUri_result.uri};
const fs = require('fs');
const url = require('url');
let filename = "";
if (got_videosources.length === 1) {
filename = folder + path.sep + 'snapshot_' + ip_entry + '.jpg';
} else {
// add _1, _2, _3 etc for cameras with multiple VideoSources
filename = folder + path.sep + 'snapshot_' + ip_entry + '_' + (src_idx + 1) + '.jpg';
}
let uri = url.parse(getUri_result.uri);
// handle the case where the camera is behind NAT
// ONVIF Standard now says use XAddr for camera
// and ignore the IP address in the Snapshot URI
uri.host = ip_entry;
uri.username = username;
uri.password = password;
if (!uri.port) uri.port = 80;
let digestRequest = require('request-digest')(username, password);
digestRequest.request({
host: 'http://' + uri.host,
path: uri.path,
port: uri.port,
encoding: null, // return data as a Buffer()
method: 'GET'
// headers: {
// 'Custom-Header': 'OneValue',
// 'Other-Custom-Header': 'OtherValue'
// }
}, function (error, response, body) {
if (error) {
// console.log('Error downloading snapshot');
// throw error;
} else {
fs.open(filename, 'w', function (err) {
// callback for file opened, or file open error
if (err) {
console.log('ERROR - cannot create output log file');
console.log(err);
console.log('');
process.exit(1);
}
fs.appendFile(filename, body, function (err) {
if (err) {
console.log('Error writing to file');
}
});
});
}
});
}
if (reply_count === reply_max) nimble_callback(); // let 'flow' move on. JPEG GET is still async
});
} // end for
} catch (err) { nimble_callback(); }
},
function (nimble_callback) {
const reply_max = got_videosources.length * 4; // x4 for TCP, UDP, HTTP and MULTICAST URLs
let reply_count = 0;
for (let src_idx = 0; src_idx < got_videosources.length; src_idx++) {
const profileToken = bestProfile[src_idx].$.token;
flow.series([
function (inner_nimble_callback) {
try {
cam_obj.getStreamUri({
protocol: 'RTSP',
stream: 'RTP-Unicast',
profileToken: profileToken
}, function (err, stream) {
if (!err) got_livestreams[src_idx].tcp = stream.uri;
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
});
} catch (err) {
inner_nimble_callback();
reply_count++;
if (reply_count == reply_max) nimble_callback();
}
},
function (inner_nimble_callback) {
try {
cam_obj.getStreamUri({
protocol: 'UDP',
stream: 'RTP-Unicast',
profileToken: profileToken
}, function (err, stream) {
if (!err) got_livestreams[src_idx].udp = stream.uri;
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
});
} catch (err) {
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
}
},
function (inner_nimble_callback) {
try {
cam_obj.getStreamUri({
protocol: 'HTTP',
stream: 'RTP-Unicast',
profileToken: profileToken
}, function (err, stream) {
if (!err) got_livestreams[src_idx].http = stream.uri;
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
});
} catch (err) {
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
}
},
function (inner_nimble_callback) {
/* Multicast is optional in Profile S, Mandatory in Profile T but could be disabled */
try {
cam_obj.getStreamUri({
protocol: 'UDP',
stream: 'RTP-Multicast',
profileToken: profileToken
}, function (err, stream, xml) {
if (!err) got_livestreams[src_idx].multicast = stream.uri;
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
});
} catch (err) {
reply_count++;
inner_nimble_callback();
if (reply_count == reply_max) nimble_callback();
}
}
]); // end of inner flow
} // end for loop
// Note nimble_callback(); is called when all work is done
},
function (nimble_callback) {
console.log('------------------------------');
console.log('Host: ' + ip_entry + ' Port: ' + port);
console.log('Date: = ' + got_date);
console.log('Info: = ' + JSON.stringify(got_info));
for (let i = 0; i < got_videosources.length; i++) {
let msg = "Video Source " + (i+1) + ' [' + got_videosources[i].$.token + '] [' + bestProfile[i].videoEncoderConfiguration.encoding + ' '
+ bestProfile[i].videoEncoderConfiguration.resolution.width + 'x' + bestProfile[i].videoEncoderConfiguration.resolution.height + ']';
console.log(msg);
if (got_snapshots[i].uri != null) {
console.log('Snapshot URI: = ' + got_snapshots[i].uri);
}
if (got_livestreams[i].tcp != null) {
console.log('Live TCP Stream: = ' + got_livestreams[i].tcp);
}
if (got_livestreams[i].udp != null) {
console.log('Live UDP Stream: = ' + got_livestreams[i].udp);
}
if (got_livestreams[i].http != null) {
console.log('Live HTTP Stream: = ' + got_livestreams[i].http);
}
if (got_livestreams[i].multicast != null) {
console.log('Live Multicast Stream: = ' + got_livestreams[i].multicast);
}
console.log('------------------------------');
}
let log_filename = folder + path.sep + 'camera_report_' + ip_entry + '.txt';
let log_fd;
fs.open(log_filename, 'w', function (err, fd) {
if (err) {
console.log('ERROR - cannot create output file ' + log_filename);
console.log(err);
console.log('');
process.exit(1);
}
log_fd = fd;
//console.log('Log File Open (' + log_filename + ')');
// write to log file in the Open callback
let msg = 'Host:= ' + ip_entry + ' Port:= ' + port + '\r\n';
if (got_date) {
msg += 'Date:= ' + got_date + '\r\n';
} else {
msg += 'Date:= unknown\r\n';
}
if (got_info) {
msg += 'Manufacturer:= ' + got_info.manufacturer + '\r\n';
msg += 'Model:= ' + got_info.model + '\r\n';
msg += 'Firmware Version:= ' + got_info.firmwareVersion + '\r\n';
msg += 'Serial Number:= ' + got_info.serialNumber + '\r\n';
msg += 'Hardware ID:= ' + got_info.hardwareId + '\r\n';
} else {
msg += 'Manufacturer:= unknown\r\n';
msg += 'Model:= unknown\r\n';
msg += 'Firmware Version:= unknown\r\n';
msg += 'Serial Number:= unknown\r\n';
msg += 'Hardware ID:= unknown\r\n';
}
for (let i = 0; i < got_videosources.length; i++) {
msg += "Video Source " + (i+1) + ' [' + got_videosources[i].$.token + '] [' + bestProfile[i].videoEncoderConfiguration.encoding + ' '
+ bestProfile[i].videoEncoderConfiguration.resolution.width + 'x' + bestProfile[i].videoEncoderConfiguration.resolution.height + ']\r\n';
if (got_snapshots[i].uri != null) {
msg += 'Snapshot URL: = ' + got_snapshots[i].uri + '\r\n';
}
if (got_livestreams[i].tcp != null) {
msg += 'Live TCP Stream: = ' + got_livestreams[i].tcp + '\r\n';
}
if (got_livestreams[i].udp != null) {
msg += 'Live UDP Stream: = ' + got_livestreams[i].udp + '\r\n';
}
if (got_livestreams[i].http != null) {
msg += 'Live HTTP Stream: = ' + got_livestreams[i].http + '\r\n';
}
if (got_livestreams[i].multicast != null) {
msg += 'Live Multicast Stream: = ' + got_livestreams[i].multicast + '\r\n';
}
}
fs.write(log_fd, msg, function (err) {
if (err)
console.log('Error writing to file');
});
});
nimble_callback();
},
]); // end flow
});
// Log ONVIF XML Messages from the Onvif Library
//c.on("rawRequest", (data) => console.log("\nTX DATA:", data));
//c.on("rawResponse", (data) => console.log("\nRX DATA:", data));
}); // foreach
}
function generate_range(start_ip, end_ip) {
let start_long = toLong(start_ip);
let end_long = toLong(end_ip);
if (start_long > end_long) {
let tmp = start_long;
start_long = end_long
end_long = tmp;
}
let range_array = [];
for (let i = start_long; i <= end_long; i++) {
range_array.push(fromLong(i));
}
return range_array;
}
//toLong taken from NPM package 'ip'
function toLong(ip) {
let ipl = 0;
ip.split('.').forEach(function (octet) {
ipl <<= 8;
ipl += parseInt(octet);
});
return (ipl >>> 0);
}
//fromLong taken from NPM package 'ip'
function fromLong(ipl) {
return ((ipl >>> 24) + '.' +
(ipl >> 16 & 255) + '.' +
(ipl >> 8 & 255) + '.' +
(ipl & 255));
}