Skip to content
Browse files

Documented some things we have got so far

  • Loading branch information...
1 parent 274b713 commit f5dfa4f199981b800cc9903adeaa00ff4ad6091c @raphaelr committed Mar 8, 2012
View
5 doc/input/_navigation.md
@@ -1,2 +1,5 @@
* [pcap-ffi](index.html)
-* [Coding Style](coding-style.html)
+* [API](api.index.html)
+ * [Opening and closing](api.open-close.html)
+* Development
+ * [Coding Style](dev.coding-style.html)
View
9 doc/input/api/index.md
@@ -0,0 +1,9 @@
+API Reference
+=============
+This section details the public facing API of `pcap-ffi`. The following convetions
+are used throughout this section:
+
+* `pcap` is the result of `require('pcap-ffi')`.
+* `handle` is a handle returned by the [`pcap.open*`](api.open-close.html) functions
+* Optional functions parameters are written in `[brackets]`. The default value is
+ specified in the parameter documentation.
View
37 doc/input/api/open-close.md
@@ -0,0 +1,37 @@
+Opening and closing devices
+===========================
+
+## pcap.openLive
+ var handle = pcap.openLive(name, [snaplen], [promiscuous], [timeout]);
+
+Opens a live capture from a physical network interface.
+
+* **`name`**: Name of the device to open, e.g. `eth0` on GNU/Linux-based systems.
+* `snaplen`: Maximum capture length of one packet.
+ Default: `65535`
+* `promiscuous`: A truthy value for this parameter enables promicuous mode, i.e.
+ the interface will capture all packets, even those addressed to other MAC
+ addresses. The effect of this parameter depends on the operating system and type
+ of interface used.
+ Default: `false`
+* `timeout`: Time to allow the capture driver to capture more packets before sending it
+ to the application in one chunk, minimizing CPU usage. A lower value therefore decreases
+ latency but increases CPU usage. A value of `0` allows the capture driver to read
+ as much packets as it can store in it's buffer before returning.
+ Default: `0`
+
+## pcap.openDead
+ var handle = pcap.openDead([linktype], [snaplen]);
+
+Opens a dead capture. Useful only for testing purposes.
+
+* `linktype`: Data-Link type of the device, see `bpf.h` in your libpcap distribution.
+ Default: `1` (Ethernet)
+* `snaplen`: Maximum capture length of one packet.
+ Default: `65535`
+
+## handle.close
+ handle.close();
+
+Closes a handle returned by the `pcap.open*` functions. Multiple calls to this function
+are ignored.
View
0 doc/input/coding-style.md → doc/input/dev/coding-style.md
File renamed without changes.

0 comments on commit f5dfa4f

Please sign in to comment.
Something went wrong with that request. Please try again.