Skip to content

Commit

Permalink
Add syntax highlighting for javascript in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmeusel authored Jul 5, 2017
1 parent d920204 commit 49f0745
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ takes care of this automatically.

To start a capture session, call `pcap.createSession` with an interface name and a pcap filter string:

var pcap = require('pcap'),
pcap_session = pcap.createSession(interface, filter);
```javascript
var pcap = require('pcap'),
pcap_session = pcap.createSession(interface, filter);
```

`interface` is the name of the interface on which to capture packets. If passed an empty string, `libpcap`
will try to pick a "default" interface, which is often just the first one in some list and not what you want.
Expand All @@ -87,9 +89,11 @@ Unless you are recklessly roaming about as root already, you'll probably want to

Listening for packets:

pcap_session.on('packet', function (raw_packet) {
// do some stuff with a raw packet
});
```javascript
pcap_session.on('packet', function (raw_packet) {
// do some stuff with a raw packet
});
```

To convert `raw_packet` into a JavaScript object that is easy to work with, decode it:

Expand All @@ -98,7 +102,9 @@ To convert `raw_packet` into a JavaScript object that is easy to work with, deco
The protocol stack is exposed as a nested set of objects. For example, the TCP destination port is part of TCP
which is encapsulated within IP, which is encapsulated within a link layer. Access it like this:

packet.link.ip.tcp.dport
```javascript
packet.link.ip.tcp.dport
```

This structure is easy to explore with `sys.inspect`.

Expand Down

0 comments on commit 49f0745

Please sign in to comment.