Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.error("usage: node pcap.js /path/to/file.pcap");
console.error();
process.exit();
}
/* NDPI Types */
var voidPtr = exports.voidPtr = ref.refType(ref.types.void);
var u_char = exports.u_char = Struct({
__u_char: ref.types.uchar,
});
var u_charPtr = exports.u_charPtr = ref.refType(u_char);
var pcap_t = exports.pcap_t = voidPtr;
var pcap_tPtr = exports.pcap_tPtr = ref.refType(pcap_t);
var pcap_handler = exports.pcap_handler = ffi.Function(ref.types.void, [
ref.refType(ref.types.uchar),
voidPtr,
ref.refType(ref.types.uchar),
]);
var pcap_handlerPtr = exports.pcap_handlerPtr = ref.refType(pcap_handler);
var uint8_t = exports.uint8_t = voidPtr;
var uint8_tPtr = exports.uint8_tPtr = ref.refType(uint8_t);
/* callback */
const onProto = function(id, packet) {
if (id > 0) { console.log("Proto: "+packet+" ("+id+")") }
}
var callback = exports.callback = ffi.Function(ref.types.void, [
ref.refType(ref.types.uchar),
voidPtr,
ref.refType(ref.types.uchar),
]);
var pcap_handlerPtr = exports.pcap_handlerPtr = ref.refType(pcap_handler);
var uint8_t = exports.uint8_t = voidPtr;
var uint8_tPtr = exports.uint8_tPtr = ref.refType(uint8_t);
/* callback */
const onProto = function(id, packet) {
if (id > 0) { console.log("Proto: "+packet+" ("+id+")") }
}
var callback = exports.callback = ffi.Function(ref.types.void, [
ref.types.int32,
ref.refType(uint8_t),
]);
var ndpi = ffi.Library('../ndpiexlib.so', {
init: [ref.types.void, [
]],
setDatalinkType: [ref.types.void, [
pcap_tPtr,
]],
processPacket: [ref.types.void, [
voidPtr,
uint8_t,
]],
finish: [ref.types.void, [
]],
/* APP VARS */
var voidPtr = exports.voidPtr = ref.refType(ref.types.void);
var u_char = exports.u_char = Struct({
__u_char: ref.types.uchar,
});
var u_charPtr = exports.u_charPtr = ref.refType(u_char);
var uint8_t = exports.uint8_t = voidPtr;
var uint8_tPtr = exports.uint8_tPtr = ref.refType(uint8_t);
// var callbackPtr = ffi.Callback(ref.types.void, [ ref.types.int32, ref.refType(ref.types.uchar) ], onProto);
// var callbackF = ffi.ForeignFunction(callbackPtr, ref.types.void, [ ref.types.int32, ref.refType(ref.types.uchar) ]);
var callback = exports.callback = ffi.Function(ref.types.void, [
ref.types.int32,
ref.refType(ref.types.uchar),
]);
var pcap_t = exports.pcap_t = voidPtr;
var pcap_tPtr = exports.pcap_tPtr = ref.refType(pcap_t);
var pcap_handler = exports.pcap_handler = ffi.Function(ref.types.void, [
ref.refType(ref.types.uchar),
voidPtr,
ref.refType(ref.types.uchar),
]);
var pcap_handlerPtr = exports.pcap_handlerPtr = ref.refType(pcap_handler);
// PCAP Header
var pcap_pkthdr = exports.pcap_pkthdr = Struct({
'ts_sec': 'long',
var u_charPtr = exports.u_charPtr = ref.refType(u_char);
var uint8_t = exports.uint8_t = voidPtr;
var uint8_tPtr = exports.uint8_tPtr = ref.refType(uint8_t);
// var callbackPtr = ffi.Callback(ref.types.void, [ ref.types.int32, ref.refType(ref.types.uchar) ], onProto);
// var callbackF = ffi.ForeignFunction(callbackPtr, ref.types.void, [ ref.types.int32, ref.refType(ref.types.uchar) ]);
var callback = exports.callback = ffi.Function(ref.types.void, [
ref.types.int32,
ref.refType(ref.types.uchar),
]);
var pcap_t = exports.pcap_t = voidPtr;
var pcap_tPtr = exports.pcap_tPtr = ref.refType(pcap_t);
var pcap_handler = exports.pcap_handler = ffi.Function(ref.types.void, [
ref.refType(ref.types.uchar),
voidPtr,
ref.refType(ref.types.uchar),
]);
var pcap_handlerPtr = exports.pcap_handlerPtr = ref.refType(pcap_handler);
// PCAP Header
var pcap_pkthdr = exports.pcap_pkthdr = Struct({
'ts_sec': 'long',
'ts_usec': 'long',
'incl_len': 'int',
'orig_len': 'int'
});
var pktHdr = exports.pktHdr = new pcap_pkthdr;
pktHdr = ref.refType(ref.types.void);