Skip to content

[WIP] Node.js bindings for `wpcap.dll` using koffi.

Notifications You must be signed in to change notification settings

Vexcited/libpcap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libpcap-ffi - libpcap FFI wrapper for Node.js

Note: This project is still in development.

Only supports Windows, for now. Contributions are welcome.

This project was made possible thanks to koffi, an awesome and fast C FFI module for Node.js.

Prerequisites

Windows

You'll need to install Npcap.

Check that you have the wpcap.dll file at C:\Windows\System32\Npcap\wpcap.dll - should be the default location.

Note that libpcap-ffi may not be compatible with WinPcap so if you had WinPcap installed before, you'll need to uninstall it or find a way to use the wpcap.dll from Npcap instead of the one from WinPcap.

Linux and macOS

Not supported yet.

Usage

Every functions can be directly imported from libpcap-ffi, so if you want to use findAllDevs, you can simply do:

// ESM
import { findAllDevs } from "libpcap-ffi";
// CJS
const { findAllDevs } = require("libpcap-ffi");

// Just use it !
const devices = findAllDevs();
console.log(devices);
/** >>> Returns the following array:
 * [
 *   {
 *     name: '\\Device\\...',
 *     description: '...',
 *     addresses: [ ... ],
 *     flags: 22
 *   },
 *   ...
 * ]
 */

Contributing

Commands

Note that we use pnpm to manage dependencies.

Command Description
pnpm install Install the dependencies.
pnpm build Bundle src directory into dist using tsup.
pnpm tsx examples/devices.ts Run an example script using tsx.

TO-DO

A list of things to do to make the library more complete.

  • Remove next attribute on Device objects.
  • Parse addresses attribute on Device objects.
    • Make an interface for the addresses attribute.
    • Read them as an array of object.
    • Make a function to parse those.
  • OpenLive
  • OpenOffline

Resources

About

[WIP] Node.js bindings for `wpcap.dll` using koffi.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published